Class: Rentjuicer::Response

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

Direct Known Subclasses

Listings::SearchResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, raise_error = false) ⇒ Response

Returns a new instance of Response.

Raises:



6
7
8
9
# File 'lib/rentjuicer/response.rb', line 6

def initialize(response, raise_error = false)
  rash_response(response)
  raise Error.new(self.body.code, self.body.message) if !success? && raise_error
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rentjuicer/response.rb', line 15

def method_missing(method_name, *args)
  if self.body.respond_to?(method_name)
    self.body.send(method_name)
  else
    super
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/rentjuicer/response.rb', line 4

def body
  @body
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rentjuicer/response.rb', line 11

def success?
  self.body && !self.body.blank? && self.body.respond_to?(:status) && self.body.status == "ok"
end