Class: Atheme::ObjectifiedHash
- Inherits:
-
Object
- Object
- Atheme::ObjectifiedHash
- Defined in:
- lib/atheme/objectified_hash.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ ObjectifiedHash
constructor
A new instance of ObjectifiedHash.
- #method_missing(key) ⇒ Object
Constructor Details
#initialize(hash) ⇒ ObjectifiedHash
Returns a new instance of ObjectifiedHash.
2 3 4 5 6 7 8 9 |
# File 'lib/atheme/objectified_hash.rb', line 2 def initialize(hash) @data = hash.inject({}) do |data, (key, value)| value = Atheme::ObjectifiedHash.new(value) if value.is_a? Hash data[key.to_s] = value data end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key) ⇒ Object
11 12 13 |
# File 'lib/atheme/objectified_hash.rb', line 11 def method_missing(key) @data.key?(key.to_s) ? @data[key.to_s] : nil end |