class Rundeck::ObjectifiedHash

Converts hashes to objects.

Public Class Methods

new(hash) click to toggle source

Creates a new ObjectifiedHash object.

# File lib/rundeck/objectified_hash.rb, line 5
def initialize(hash)
  @hash = hash
  @data = hash.each_with_object({}) do |(key, value), data|
    value = if value.is_a?(Hash)
              ObjectifiedHash.new(value)
            elsif value.is_a?(Array)
              value.map { |e| ObjectifiedHash.new(e) }
            else
              value
            end
    data[key.to_s.downcase] = value
    data
  end
end

Public Instance Methods

method_missing(key) click to toggle source

Respond if the requested method is a key in the data hash.

Calls superclass method
# File lib/rundeck/objectified_hash.rb, line 30
def method_missing(key)
  @data.key?(key.to_s) ? @data[key.to_s] : super
end
respond_to?(method) click to toggle source

Overload the parent method so this properly returns whether the instance of this object responds to the given method.

Calls superclass method
# File lib/rundeck/objectified_hash.rb, line 36
def respond_to?(method)
  @data.key?(method.to_s) || super
end
to_h()
Alias for: to_hash
to_hash() click to toggle source

Return the original hash object

@return [Hash] the original hash

# File lib/rundeck/objectified_hash.rb, line 23
def to_hash
  @hash
end
Also aliased as: to_h