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
link(rel = nil)
click to toggle source
# File lib/consumer/proxy.rb, line 14 def link(rel = nil) return method_missing(:link) if rel.nil? _link = self["link"] || self["links"] _link = [_link].flatten _link = _link.find {|l| l.is_a?(Hash) and l["rel"] == rel } methodize_me(_link) end
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