Sha256: cc112e1f2aaeb2647a6bf3f1ff3ceb9cc667559c9d498c3333f7e82fb7273589
Contents?: true
Size: 838 Bytes
Versions: 1
Compression:
Stored size: 838 Bytes
Contents
module Goauth2 class HashResponse attr_accessor :hash, :response def initialize(response) @response = response if response.is_a?(Hash) @hash = response else @hash = JSON.parse(response.body) end @hash = @hash['data'] if @hash['data'] end def first wrap(@hash.first) end def method_missing(name) val = @hash[name] if @hash.key? name @hash.each { |k,v| val = v if k.to_s.to_sym == name } unless val if val return wrap(val) end super.method_missing name end private def wrap(val) if val.is_a? Hash Goauth2::HashResponse.new(val) elsif val.is_a? Array Goauth2::ArrayResponse.new(val) else val end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
goauth2-0.0.12 | lib/goauth2/hash_response.rb |