Class: Facile::Response

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

Defined Under Namespace

Classes: Wrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Response

Returns a new instance of Response.



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

def initialize(options)
  options.each do |k,v|
    self.send("#{k}=", v)
  end

  wrap_body(raw_body)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



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

def method_missing(method, *args, &block)
  if body.respond_to?(method)
    body.send(method, args.first)
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



22
23
24
# File 'lib/facile/response.rb', line 22

def body
  @body
end

#headersObject

Returns the value of attribute headers.



22
23
24
# File 'lib/facile/response.rb', line 22

def headers
  @headers
end

#raw_bodyObject

Returns the value of attribute raw_body.



22
23
24
# File 'lib/facile/response.rb', line 22

def raw_body
  @raw_body
end

#requestObject

Returns the value of attribute request.



22
23
24
# File 'lib/facile/response.rb', line 22

def request
  @request
end

#responseObject

Returns the value of attribute response.



22
23
24
# File 'lib/facile/response.rb', line 22

def response
  @response
end

#statusObject

Returns the value of attribute status.



22
23
24
# File 'lib/facile/response.rb', line 22

def status
  @status
end

Instance Method Details

#wrap_body(body) ⇒ Object



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

def wrap_body(body)
  @body = ::Facile::Response::Wrapper.parse(body, headers)
end