class Consumer::Proxy

Public Class Methods

new(hash) click to toggle source
# File lib/consumer/proxy.rb, line 4
def initialize(hash)
  hash.each { |k, v| self[k.to_s] = v }
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/consumer/proxy.rb, line 8
def method_missing(method, *args, &block)
  _method = method.to_s
  super if args.any? or not respond_to?(_method)
  return methodize_me(self[_method])
end
respond_to?(method) click to toggle source
Calls superclass method
# File lib/consumer/proxy.rb, line 24
def respond_to?(method)
  self.has_key?(method.to_s) or super
end

Private Instance Methods

methodize_me(obj) click to toggle source
# File lib/consumer/proxy.rb, line 29
def methodize_me(obj)
  if obj.is_a? Hash
    Consumer::Proxy.new(obj)
  elsif obj.is_a? Array
    obj.map { |i| methodize_me(i) }
  else
    obj
  end
end