Class: ExportoAPI::Base

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Base

Returns a new instance of Base.



16
17
18
19
# File 'lib/exporto_api/object.rb', line 16

def initialize(attributes)
  @original_response = deep_freeze(attributes)
  super(to_ostruct(attributes))
end

Instance Attribute Details

#original_response ⇒ Object (readonly)

Returns the value of attribute original_response.



8
9
10
# File 'lib/exporto_api/object.rb', line 8

def original_response
  @original_response
end

Class Method Details

.new(attributes) ⇒ Object



10
11
12
13
14
# File 'lib/exporto_api/object.rb', line 10

def self.new(attributes)
  return attributes.map { |item| super(item) } if attributes.is_a?(Array)

  super
end

Instance Method Details

#raw ⇒ Object



27
28
29
# File 'lib/exporto_api/object.rb', line 27

def raw
  @original_response
end

#to_hash ⇒ Object Also known as: to_h



21
22
23
# File 'lib/exporto_api/object.rb', line 21

def to_hash
  ostruct_to_hash(self)
end