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.



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

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 (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end