Class: Tmdb::Resource
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query_url ⇒ Object
readonly
Returns the value of attribute query_url.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(query_url, filters = {}) ⇒ Resource
constructor
A new instance of Resource.
Methods included from Utils
Constructor Details
#initialize(query_url, filters = {}) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 |
# File 'lib/tmdb/resource.rb', line 8 def initialize(query_url, filters={}) @params = filters @query_url = query_url end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/tmdb/resource.rb', line 6 def params @params end |
#query_url ⇒ Object (readonly)
Returns the value of attribute query_url.
6 7 8 |
# File 'lib/tmdb/resource.rb', line 6 def query_url @query_url end |
Instance Method Details
#get ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tmdb/resource.rb', line 13 def get request_params = Api.params.merge(@params) begin response = RestClient.get Api::BASE_URI + query_url, Api::JSON_HEADERS.merge(params: request_params) rescue => e parsed_exception_rs = parse_json(e.response) if parsed_exception_rs['status_message'].present? raise Tmdb::Error, parsed_exception_rs['status_message'] else raise Tmdb::Error, e.response end end parse_json(response) end |