Class: TMDb::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tmdb-api/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

Internal: creates a new TMDb::Base object.

attributes - Attributes fetched from the API.



27
28
29
# File 'lib/tmdb-api/base.rb', line 27

def initialize(attributes = {})
  set_attributes(attributes)
end

Class Method Details

.bad_response(response) ⇒ Object

Internal: Raises an exception depending on the type of the response.

response - Result of a request.

Raises an exception.

Raises:

  • (StandardError)


17
18
19
20
21
22
# File 'lib/tmdb-api/base.rb', line 17

def self.bad_response(response)
  if response.class == HTTParty::Response
    raise ArgumentError, response['status_message']
  end
  raise StandardError, 'Unkown error'
end