Class: SocialProfile::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/social_profile/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, response, options = {}) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
# File 'lib/social_profile/response.rb', line 5

def initialize(uri, response, options={})
  @uri          = uri
  @response     = response
  @body         = response.body || options[:body]
  @headers      = response.to_hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)



23
24
25
26
27
28
29
# File 'lib/social_profile/response.rb', line 23

def method_missing(name, *args, &block)
  if response.respond_to?(name)
    response.send(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/social_profile/response.rb', line 3

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/social_profile/response.rb', line 3

def headers
  @headers
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/social_profile/response.rb', line 3

def response
  @response
end

#uriObject (readonly)

Returns the value of attribute uri.



3
4
5
# File 'lib/social_profile/response.rb', line 3

def uri
  @uri
end

Instance Method Details

#codeObject



12
13
14
# File 'lib/social_profile/response.rb', line 12

def code
  response.code.to_i
end

#respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/social_profile/response.rb', line 16

def respond_to?(name)
  return true if [:uri, :response, :body, :headers].include?(name)
  response.respond_to?(name)
end