Sha256: 0e47c86d042e3c4c1547f31d9ef7609a65087c1bb8abe7afc9afd3c88ddb45f3
Contents?: true
Size: 1.16 KB
Versions: 19
Compression:
Stored size: 1.16 KB
Contents
module Neo4j module RelationshipMixin module ClassMethods def load_wrapper(rel) wrapped_rel = self.orig_new wrapped_rel.init_on_load(rel) wrapped_rel end # Creates a relationship between given nodes. # # You can use two callback method to initialize the relationship # init_on_load:: this method is called when the relationship is loaded from the database # init_on_create:: called when the relationship is created, will be provided with the same argument as the new method # # ==== Parameters (when creating a new relationship in db) # type:: the key and value to be set # from_node:: create relationship from this node # to_node:: create relationship to this node # props:: optional hash of properties to initialize the create relationship with # def new(*args) type, from_node, to_node = args rel = Neo4j::Relationship.create(type, from_node, to_node) wrapped_rel = super() wrapped_rel.init_on_load(rel) wrapped_rel.init_on_create(*args) wrapped_rel end alias_method :create, :new end end end
Version data entries
19 entries across 19 versions & 1 rubygems