Method: Neography::PropertyContainer#initialize
- Defined in:
- lib/neography/property_container.rb
#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 |