Package org.jruby

Examples of org.jruby.RubyClass.allocate()


            throw runtime.newRuntimeError("Datomic Exception: " + t.getMessage());
        }

        if (results == null) return context.getRuntime().getNil();
        RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Set");
        DiametricSet diametric_set = (DiametricSet)clazz.allocate();
        diametric_set.init(results);
        return diametric_set;
    }

    private static Database getDatabase(Object value) {
View Full Code Here


                            clj_map,
                            DiametricService.keywords.get(ruby_key.toString()),
                            convertRubyValueToJava(context, ruby_value, valueTypes[i]));
            }
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Function");
            DiametricFunction ruby_function = (DiametricFunction) clazz.allocate();
            Var function_fn = DiametricService.getFn("datomic.api", "function");
            ruby_function.init((datomic.function.Function) function_fn.invoke(clj_map));
            return ruby_function;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
View Full Code Here

        if (saved_connection == null) throw runtime.newRuntimeError("Connection is not established");
        try {
            Object database = DiametricService.getFn("datomic.api", "db").invoke(saved_connection.toJava());
            Object entity = DiametricService.getFn("datomic.api", "entity").invoke(database, dbid);
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Entity");
            DiametricEntity ruby_entity = (DiametricEntity)clazz.allocate();
            ruby_entity.init(entity);
            return ruby_entity;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
View Full Code Here

                RubyArray array = RubyArray.newArray(runtime, set.size());
                Iterator iter = set.iterator();
                while (iter.hasNext()) {
                    Object e = iter.next();
                    RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Entity");
                    DiametricEntity ruby_entity = (DiametricEntity)clazz.allocate();
                    ruby_entity.init(e);
                    array.append(ruby_entity);
                }
                return array;
            } catch (Throwable t) {
View Full Code Here

    }

    @JRubyMethod(name="new", meta=true)
    public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject arg) {
        RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Fn");
        DiametricFn diametric_object = (DiametricFn)clazz.allocate();
        diametric_object.init((List)DiametricUtils.convertRubyToJava(context, arg));
        return diametric_object;
    }

    @JRubyMethod
View Full Code Here

                drop_or_take_fn = (Var)var.invoke("(defn drop-or-take [n target] (apply vector (drop n target)))");
                DiametricService.fnMap.put("drop-or-take", drop_or_take_fn);
            }
            PersistentVector value = (PersistentVector)drop_or_take_fn.invoke(n, target);
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Collection");
            DiametricCollection ruby_collection = (DiametricCollection)clazz.allocate();
            ruby_collection.init(value);
            return ruby_collection;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
View Full Code Here

                first_n_fn = (Var)var.invoke("(defn first-n [n target] (apply vector (take n target)))");
                DiametricService.fnMap.put("first-n", first_n_fn);
            }
            PersistentVector value = (PersistentVector)first_n_fn.invoke(n, target);
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Collection");
            DiametricCollection ruby_collection = (DiametricCollection)clazz.allocate();
            ruby_collection.init(value);
            return ruby_collection;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
View Full Code Here

    private IRubyObject createEntity(ThreadContext context, Long entityId) {
        try {
            Var entity_fn = DiametricService.getFn("datomic.api", "entity");
            Entity entity = (Entity) entity_fn.invoke(database, entityId);
            RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Entity");
            DiametricEntity diametric_entity = (DiametricEntity)clazz.allocate();
            diametric_entity.init(entity);
            return diametric_entity;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
View Full Code Here

            Keyword entityKey = (Keyword) keyword_fn.invoke(arg.toString());
            Var entity_fn = DiametricService.getFn("datomic.api", "entity");
            Entity entity = (Entity) entity_fn.invoke(database, entityKey);
            datomic.function.Function function = (Function) entity.get(DiametricService.keywords.get("db/fn"));
            RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Function");
            DiametricFunction diametric_function = (DiametricFunction)clazz.allocate();
            diametric_function.init(function);
            return diametric_function;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
View Full Code Here

    public IRubyObject as_of(ThreadContext context, IRubyObject arg) {
        Object t_value = DiametricUtils.convertRubyToJava(context, arg);
        try {
            Database db_asof_t = (Database) DiametricService.getFn("datomic.api", "as-of").invoke(database, t_value);
            RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Database");
            DiametricDatabase diametric_database = (DiametricDatabase)clazz.allocate();
            diametric_database.init(db_asof_t);
            return diametric_database;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError("Datomic Error: " + t.getMessage());
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.