Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the functions basis_t and history #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions ext/diametric/DiametricDatabase.java
Expand Up @@ -121,6 +121,29 @@ public IRubyObject as_of(ThreadContext context, IRubyObject arg) {
}
}

@JRubyMethod
public IRubyObject basis_t(ThreadContext context) {
try {
Long time = (Long) DiametricService.getFn("datomic.api", "basis-t").invoke(database);
return context.getRuntime().newFixnum(time);
} catch (Throwable t) {
throw context.getRuntime().newRuntimeError("Datomic Error: " + t.getMessage());
}
}

@JRubyMethod
public IRubyObject history(ThreadContext context) {
try {
Database db_history = (Database) DiametricService.getFn("datomic.api", "history").invoke(database);
RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Database");
DiametricDatabase diametric_database = (DiametricDatabase)clazz.allocate();
diametric_database.init(db_history);
return diametric_database;
} catch (Throwable t) {
throw context.getRuntime().newRuntimeError("Datomic Error: " + t.getMessage());
}
}

@JRubyMethod
public IRubyObject since(ThreadContext context, IRubyObject arg) {
Object t_value = DiametricUtils.convertRubyToJava(context, arg);
Expand Down