Class: NeoRest::Relationship
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- NeoRest::Relationship
- Defined in:
- lib/NeoRest/relationship.rb
Instance Attribute Summary collapse
-
#end_id ⇒ Object
readonly
Returns the value of attribute end_id.
-
#neo_id ⇒ Object
readonly
Returns the value of attribute neo_id.
-
#neo_url ⇒ Object
readonly
Returns the value of attribute neo_url.
-
#start_id ⇒ Object
readonly
Returns the value of attribute start_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(hash = nil) ⇒ Relationship
constructor
A new instance of Relationship.
- #update(properties = {}) ⇒ Object
Constructor Details
#initialize(hash = nil) ⇒ Relationship
Returns a new instance of Relationship.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/NeoRest/relationship.rb', line 11 def initialize( hash = nil ) @table = {} if hash @neo_id = hash["self"].split('/').last @neo_url = hash["self"] @start_id = hash["start"].split('/').last @end_id = hash["end"].split('/').last @type = hash["type"] for key, value in hash["data"] @table[key.to_sym] = value new_ostruct_member(key) end end end |
Instance Attribute Details
#end_id ⇒ Object (readonly)
Returns the value of attribute end_id.
9 10 11 |
# File 'lib/NeoRest/relationship.rb', line 9 def end_id @end_id end |
#neo_id ⇒ Object (readonly)
Returns the value of attribute neo_id.
9 10 11 |
# File 'lib/NeoRest/relationship.rb', line 9 def neo_id @neo_id end |
#neo_url ⇒ Object (readonly)
Returns the value of attribute neo_url.
9 10 11 |
# File 'lib/NeoRest/relationship.rb', line 9 def neo_url @neo_url end |
#start_id ⇒ Object (readonly)
Returns the value of attribute start_id.
9 10 11 |
# File 'lib/NeoRest/relationship.rb', line 9 def start_id @start_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/NeoRest/relationship.rb', line 9 def type @type end |
Class Method Details
.delete(relationship_id) ⇒ Object
60 61 62 |
# File 'lib/NeoRest/relationship.rb', line 60 def delete relationship_id RestClient.delete( "#{$neo_base_url}/relationship/#{relationship_id}" ) end |
.load(relationship_id) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/NeoRest/relationship.rb', line 47 def load relationship_id RestClient.get( "#{$neo_base_url}/relationship/#{relationship_id}", :accept => :json ){ |response, request, result, &block| case response.code when 200 NeoRest::Node.new( JSON.parse( response ) ) when 404 return nil else response.return!(request, result, &block) end } end |
Instance Method Details
#delete ⇒ Object
41 42 43 |
# File 'lib/NeoRest/relationship.rb', line 41 def delete NeoRest::Relationship.delete neo_id end |
#update(properties = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/NeoRest/relationship.rb', line 27 def update properties = {} if not properties.empty? @table.each { | key, value | delete_field( key ) } @table.clear for key, value in properties @table[key.to_sym] = value new_ostruct_member(key) end end RestClient.put( "#{$neo_base_url}/relationship/#{neo_id}/properties", @table.to_json, :content_type => :json, :accept => :json ) end |