Sha256: 764804a5aafd3cd723804f6f5c8fdbce5b907853a710555bc9536a5d9b41dc86
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
module Neoid module Relationship module InstanceMethods def neo_find_by_id Neoid.db.get_relationship_index(self.class.neo_index_name, :ar_id, self.id) end def neo_create options = self.class.neoidable_options start_node = self.send(options[:start_node]) end_node = self.send(options[:end_node]) return unless start_node && end_node relationship = Neography::Relationship.create( options[:type], start_node.neo_node, end_node.neo_node ) Neoid.db.add_relationship_to_index(self.class.neo_index_name, :ar_id, self.id, relationship) Neoid::logger.info "Relationship#neo_create #{self.class.name} #{self.id}, index = #{self.class.neo_index_name}" relationship end def neo_load(relationship) Neography::Relationship.load(relationship) end def neo_destroy return unless neo_relationship Neoid.db.remove_relationship_from_index(self.class.neo_index_name, neo_relationship) neo_relationship.del end def neo_relationship _neo_representation end end def self.included(receiver) receiver.extend Neoid::ModelAdditions::ClassMethods receiver.send :include, Neoid::ModelAdditions::InstanceMethods receiver.send :include, InstanceMethods receiver.after_create :neo_create receiver.after_destroy :neo_destroy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
neoid-0.0.2 | lib/neoid/relationship.rb |