Class: MyOpenStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/poolparty/core/my_open_struct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ MyOpenStruct

Returns a new instance of MyOpenStruct.



7
8
9
10
# File 'lib/poolparty/core/my_open_struct.rb', line 7

def initialize(h)
  @keys = h.keys
  super
end

Instance Attribute Details

#keysObject

Returns the value of attribute keys.



6
7
8
# File 'lib/poolparty/core/my_open_struct.rb', line 6

def keys
  @keys
end

Instance Method Details

#to_hashObject



11
12
13
14
15
16
17
# File 'lib/poolparty/core/my_open_struct.rb', line 11

def to_hash
  m = {}
  @keys.map do |key|
    m.update( {key => self.send(key)} )
  end
  m
end