Class: EngagingNetworks::Response::Object
- Inherits:
-
Object
- Object
- EngagingNetworks::Response::Object
- Includes:
- Comparable
- Defined in:
- lib/engaging_networks/response/object.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
-
#initialize(row) ⇒ Object
constructor
A new instance of Object.
Constructor Details
#initialize(row) ⇒ Object
Returns a new instance of Object.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/engaging_networks/response/object.rb', line 8 def initialize(row) if row.has_key? 'EaColumn' @fields = row['EaColumn'].inject({}) do |hash, item| hash[item['name']] = item['__content__'] # TODO cast based on item['type']? hash end else @fields = row end # create accessors for each field @fields.each do |name, val| # substitute underscore for space method_name = name.sub(' ','_') self.class.send(:define_method, method_name) { @fields[name] } end end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
6 7 8 |
# File 'lib/engaging_networks/response/object.rb', line 6 def fields @fields end |