Class: TumblrWrapper::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response

Returns a new instance of Response.



3
4
5
6
7
8
# File 'lib/tumblr_wrapper/response.rb', line 3

def initialize(faraday_response)
  @faraday_response = faraday_response
  @status = faraday_response.status
  @response = faraday_response.body["response"]
  parse_message
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)



24
25
26
27
28
29
30
31
# File 'lib/tumblr_wrapper/response.rb', line 24

def method_missing(meth, *args, &block)
  if response && response.keys.include?(meth.to_s)
    r = response[meth.to_s]
    r.respond_to?(:keys) ? r.with_indifferent_access : r
  else
    super
  end
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



2
3
4
# File 'lib/tumblr_wrapper/response.rb', line 2

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



2
3
4
# File 'lib/tumblr_wrapper/response.rb', line 2

def status
  @status
end