Class: ActiveWrapper::Gems::SimpleStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/active_wrapper/gems.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ SimpleStruct

Returns a new instance of SimpleStruct.



14
15
16
17
18
19
20
# File 'lib/active_wrapper/gems.rb', line 14

def initialize(hash)
  @hash = hash
  @hash.each do |key, value|
    self.class.send(:define_method, key) { hash[key] }
    self.class.send(:define_method, "#{key}=") { |v| hash[key] = v }
  end
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



12
13
14
# File 'lib/active_wrapper/gems.rb', line 12

def hash
  @hash
end