Class: CurrencyConversion::Object
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- CurrencyConversion::Object
- Defined in:
- lib/currency-conversion/object.rb
Overview
Object
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Object
constructor
A new instance of Object.
- #to_ostruct(obj) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Object
Returns a new instance of Object.
6 7 8 |
# File 'lib/currency-conversion/object.rb', line 6 def initialize(attributes) super to_ostruct(attributes) end |
Instance Method Details
#to_ostruct(obj) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/currency-conversion/object.rb', line 10 def to_ostruct(obj) if obj.is_a?(Hash) OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h) elsif obj.is_a?(Array) obj.map { |o| to_ostruct(o) } else obj end end |