Class: APIStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/ey_services_api/api_struct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(atts = {}) ⇒ APIStruct

Returns a new instance of APIStruct.



4
5
6
7
8
9
# File 'lib/ey_services_api/api_struct.rb', line 4

def initialize(atts = {})
  #converting all keys of atts to Symbols
  @raw = atts
  atts = Hash[atts.map {|k,v| [k.to_sym, v]}]
  super(*atts.values_at(*self.members.map(&:to_sym)))
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



2
3
4
# File 'lib/ey_services_api/api_struct.rb', line 2

def raw
  @raw
end

Instance Method Details

#to_hashObject



11
12
13
# File 'lib/ey_services_api/api_struct.rb', line 11

def to_hash
  Hash[members.map(&:to_sym).zip(entries)]
end