Class: ConfigMapper::ObjectAsHash

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ ObjectAsHash

Returns a new instance of ObjectAsHash.



63
64
65
# File 'lib/config_mapper.rb', line 63

def initialize(target)
  @target = target
end

Class Method Details

.[](target) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/config_mapper.rb', line 55

def self.[](target)
  if target.is_a?(Hash)
    target
  else
    ObjectAsHash.new(target)
  end
end

Instance Method Details

#[](key) ⇒ Object



67
68
69
# File 'lib/config_mapper.rb', line 67

def [](key)
  @target.public_send(key)
end

#[]=(key, value) ⇒ Object



71
72
73
# File 'lib/config_mapper.rb', line 71

def []=(key, value)
  @target.public_send("#{key}=", value)
end