Class: Gitlab::ObjectifiedHash
- Inherits:
-
Object
- Object
- Gitlab::ObjectifiedHash
- Defined in:
- lib/gitlab/objectified_hash.rb
Overview
Converts hashes to the objects.
Instance Method Summary collapse
-
#initialize(hash) ⇒ ObjectifiedHash
constructor
Creates a new ObjectifiedHash.
-
#method_missing(key) ⇒ Object
Delegate to ObjectifiedHash.
Constructor Details
#initialize(hash) ⇒ ObjectifiedHash
Creates a new ObjectifiedHash.
5 6 7 8 9 10 11 |
# File 'lib/gitlab/objectified_hash.rb', line 5 def initialize(hash) @data = hash.inject({}) do |data, (key,value)| value = 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
Delegate to ObjectifiedHash
14 15 16 |
# File 'lib/gitlab/objectified_hash.rb', line 14 def method_missing(key) @data.key?(key.to_s) ? @data[key.to_s] : nil end |