Method: OEHClient::Data::Node#initialize
- Defined in:
- lib/oehclient/data/node.rb
permalink #initialize(data) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/oehclient/data/node.rb', line 6 def initialize(data) # Raise an exception if the data passed is not already a hash # based on the type of object that is passed, create the proper attribute accessor # to allow easy access to data. For example, a simple value in the structure called # firstName will be represented in the object as my_structure.first_name. Simple # object are represented as related node classes. For example a Preference node with # an attribute of nonSmokingRoom will be represented as my_structure.preference.non_smoking_room data.each do | key, value | (value.kind_of?(Array) ? add_collection(key, value) : add_attribute(key, value)) end end |