lib/neoid/relationship.rb in neoid-0.0.1 vs lib/neoid/relationship.rb in neoid-0.0.2
- old
+ new
@@ -1,10 +1,10 @@
module Neoid
module Relationship
module InstanceMethods
def neo_find_by_id
- Neoid.db.get_relationship_index(neo_index_name, :ar_id, self.id)
+ Neoid.db.get_relationship_index(self.class.neo_index_name, :ar_id, self.id)
end
def neo_create
options = self.class.neoidable_options
@@ -17,32 +17,32 @@
options[:type],
start_node.neo_node,
end_node.neo_node
)
- Neoid.db.add_relationship_to_index(neo_index_name, :ar_id, self.id, relationship)
+ 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(neo_index_name, neo_relationship)
- puts neo_relationship.del
+ 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)
- Neoid.db.create_relationship_index(receiver.name.tableize)
-
receiver.extend Neoid::ModelAdditions::ClassMethods
receiver.send :include, Neoid::ModelAdditions::InstanceMethods
receiver.send :include, InstanceMethods
receiver.after_create :neo_create
\ No newline at end of file