Class: GoogleOAuth::HashResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/google_oauth/hash_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response_hash) ⇒ HashResponse

Returns a new instance of HashResponse.



4
5
6
7
# File 'lib/google_oauth/hash_response.rb', line 4

def initialize(response_hash)
  @hash = response_hash
  @hash = @hash['data'] if @hash['data']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/google_oauth/hash_response.rb', line 13

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

Instance Method Details

#firstObject



9
10
11
# File 'lib/google_oauth/hash_response.rb', line 9

def first
  wrap(@hash.first)
end