class Gitlab::ObjectifiedHash
Converts hashes to the objects.
def initialize(hash)
def initialize(hash) @hash = hash @data = hash.each_with_object({}) do |(key, value), data| value = ObjectifiedHash.new(value) if value.is_a? Hash data[key.to_s] = value end end
def inspect
-
(String)
- Formatted string with the class name, object id and original hash.
def inspect "#<#{self.class}:#{object_id} {hash: #{@hash.inspect}}" end
def method_missing(key)
def method_missing(key) @data.key?(key.to_s) ? @data[key.to_s] : super end
def respond_to_missing?(method_name, include_private = false)
def respond_to_missing?(method_name, include_private = false) @hash.keys.map(&:to_sym).include?(method_name.to_sym) || super end
def to_hash
-
(Hash)
- The original hash.
def to_hash @hash end