Module: N4j::Entity::Representation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/n4j/representation.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #<=>(another_object) ⇒ Object
- #body_hash ⇒ Object
- #create_hash(opts = {}) ⇒ Object
- #create_path ⇒ Object
- #destroy_hash(opts = {}) ⇒ Object
- #path ⇒ Object
- #persist_hash(opts = {}) ⇒ Object
- #show_hash(opts = {}) ⇒ Object
- #to_key ⇒ Object
- #update_hash(opts = {}) ⇒ Object
- #update_path ⇒ Object
- #url ⇒ Object
Instance Method Details
#<=>(another_object) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/n4j/representation.rb', line 9 def <=>(another_object) if self.class.ancestors.include?(N4j::Entity) url <=> another_object.url else super(another_object) end end |
#body_hash ⇒ Object
38 39 40 |
# File 'lib/n4j/representation.rb', line 38 def body_hash raise 'Override in Node/Relationship' end |
#create_hash(opts = {}) ⇒ Object
48 49 50 |
# File 'lib/n4j/representation.rb', line 48 def create_hash(opts={}) { :to => create_path, :method => 'POST', :body => body_hash }.merge(opts) end |
#create_path ⇒ Object
30 31 32 |
# File 'lib/n4j/representation.rb', line 30 def create_path raise 'Override in Node/Relationship' end |
#destroy_hash(opts = {}) ⇒ Object
56 57 58 |
# File 'lib/n4j/representation.rb', line 56 def destroy_hash(opts={}) {:to => path, :method => 'DELETE'}.merge(opts) end |
#path ⇒ Object
25 26 27 28 |
# File 'lib/n4j/representation.rb', line 25 def path from_neo4j_relative['self'] || (place_in_batch ? "{#{place_in_batch}}" : nil) end |
#persist_hash(opts = {}) ⇒ Object
42 43 44 45 46 |
# File 'lib/n4j/representation.rb', line 42 def persist_hash(opts = {}) if needs_persist? persisted? ? update_hash(opts) : create_hash(opts) end end |
#show_hash(opts = {}) ⇒ Object
60 61 62 |
# File 'lib/n4j/representation.rb', line 60 def show_hash(opts={}) {:to => path, :method => 'GET'}.merge(opts) end |
#to_key ⇒ Object
17 18 19 |
# File 'lib/n4j/representation.rb', line 17 def to_key persisted? ? [path[/\d+\Z/]] : nil end |
#update_hash(opts = {}) ⇒ Object
52 53 54 |
# File 'lib/n4j/representation.rb', line 52 def update_hash(opts={}) {:to => update_path, :method => 'PUT', :body => body_hash}.merge(opts) end |
#update_path ⇒ Object
34 35 36 |
# File 'lib/n4j/representation.rb', line 34 def update_path from_neo4j_relative['properties'] end |
#url ⇒ Object
21 22 23 |
# File 'lib/n4j/representation.rb', line 21 def url from_neo4j['self'] end |