class Twocheckout::HashObject

Public Class Methods

new(hash) click to toggle source
# File lib/twocheckout/hash_object.rb, line 6
def initialize(hash)
  @hash = hash
end

Public Instance Methods

inspect() click to toggle source
# File lib/twocheckout/hash_object.rb, line 33
def inspect
  "#<#{self.class.name}:#{self._key}> #{pp @hash}"
end
method_missing(name) click to toggle source
Calls superclass method
# File lib/twocheckout/hash_object.rb, line 10
def method_missing(name)
  name = name.to_s
  if @hash.key? name
    result = @hash[name]
    if result.is_a?(Hash)
      result = HashObject.new(result)
      @hash[name] = result
    end
    if result.is_a?(Array)
      new_array = []
      result.each do |item|
        new_item = item.is_a?(Hash) ? HashObject.new(item) : item
        new_array << new_item
      end
      new_array.freeze
      result = new_array
      @hash[name] = result
    end
    return result
  end
  super.method_missing name
end

Protected Instance Methods

_key() click to toggle source
# File lib/twocheckout/hash_object.rb, line 39
def _key
  self.object_id.to_s
end