Class: OEXRWrapper::Object

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/oexrwrapper/object.rb

Direct Known Subclasses

Latest

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Object

Returns a new instance of Object.



5
6
7
# File 'lib/oexrwrapper/object.rb', line 5

def initialize(attributes)
  super to_ostruct attributes
end

Instance Method Details

#to_ostruct(attributes) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/oexrwrapper/object.rb', line 9

def to_ostruct(attributes)
  case attributes
  when Hash
    OpenStruct.new(attributes.transform_values { |val| to_ostruct(val) })
  when Array
    attributes.map { |o| to_ostruct(o) }
  else
    attributes
  end
end