Class: Neography::PropertyContainer
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Neography::PropertyContainer
- Defined in:
- lib/neography/property_container.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#neo_id ⇒ Object
readonly
Returns the value of attribute neo_id.
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ PropertyContainer
constructor
A new instance of PropertyContainer.
Constructor Details
#initialize(hash = nil) ⇒ PropertyContainer
Returns a new instance of PropertyContainer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/neography/property_container.rb', line 5 def initialize(hash=nil) @table = {} unless hash.nil? if hash["self"] # coming from REST API @neo_id = hash["self"].split('/').last data = hash["data"] elsif hash.is_a? Neography::Node # is already a Neography::Node @neo_id = hash.neo_id data = Hash[*hash.attributes.collect{|x| [x.to_sym, hash.send(x)]}.flatten] elsif hash["data"] # coming from CYPHER @neo_id = hash["data"].first.first["self"].split('/').last data = hash["data"].first.first["data"] end else data = [] end unless data.nil? for k,v in data new_ostruct_member(k.to_sym, v) end end end |
Instance Attribute Details
#neo_id ⇒ Object (readonly)
Returns the value of attribute neo_id.
3 4 5 |
# File 'lib/neography/property_container.rb', line 3 def neo_id @neo_id end |