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

Version Path
neo4j-1.2.4-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.2.3-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.2.2-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.2.1-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.2.0-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.4-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.3-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.2-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.1-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.0-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.0.beta.3-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.0.beta.2-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.1.0.beta.1-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.0.0-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.0.0.beta.32-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.0.0.beta.31-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.0.0.beta.30-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.0.0.beta.29-java lib/neo4j/relationship_mixin/class_methods.rb
neo4j-1.0.0.beta.28-java lib/neo4j/relationship_mixin/class_methods.rb