Sha256: 5704f2949d4dbcd076c2a4c36d30c891da11f11b84db2f10cb74bd5731853e31
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
module N4j::Node autoload :AutoRelate, 'n4j/auto_relate' extend ActiveSupport::Concern included do include AutoRelate # include N4j::Entity end module ClassMethods def find(n) find_by_node_id(n) end def find_by_node_id(n) find_by_path("/node/#{n}") end def find_by_path(path) path.sub!(N4j.neo4j_url_prefix,'') result = N4j.batch([{:to => path, :method => 'GET'}]) new(result.first['body']) end def service_root find_by_node_id(0) end end def initialize(hsh) super(hsh) unless N4j.neo4j_hash?(hsh) self.data = hsh.dup end end def create_path '/node' end def body_hash data end def dependent relationships end def connected_unsaved new_relationships end def post_save clear_new_relationships! end def relationships(direction = 'all_relationships', types = [], clear_cache = false) @relationship_cache ||= {} if persisted? path = from_neo4j_relative[direction] + '/' + [types].flatten.join('&') @relationship_cache.delete(path) if clear_cache @relationship_cache[path] ||= GenericRelationship.find_by_node_path(path) else [] end end def entity_type 'node' end def traverse(opts = {}) # Started this approach, stoppedto investigate Cypher defaults = {:start => path, :instantiate_with => self.class } N4j::Traversal.new(:start => path) end def cypher(opts = {}) defaults = {:start => self, :instantiate_with => self.class} N4j::Cypher.new(defaults.merge(opts)) end def new_relationships @new_relationships ||= [] end def clear_new_relationships! @new_relationships = [] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
n4j-0.0.1.4 | lib/n4j/node.rb |