lib/ruby-tmdb3/tmdb.rb in ruby-tmdb3-0.3.2 vs lib/ruby-tmdb3/tmdb.rb in ruby-tmdb3-0.3.3
- old
+ new
@@ -47,14 +47,15 @@
raise ArgumentError, "Invalid data." if(data.nil? || (data.class != Hash))
method, action = method.split '/'
data = {
- api_key: Tmdb.api_key,
- language: language
+ :api_key => Tmdb.api_key
}.merge(data)
+ data.merge!(:language => language) if language
+
# Addressable can only handle hashes whose values respond to to_str, so lets be nice and convert things.
query_values = {}
data.each do |key,value|
if not value.respond_to?(:to_str) and value.respond_to?(:to_s)
query_values[key] = value.to_s
@@ -69,11 +70,11 @@
if data.has_key?(:id)
uri.query_values = query_values
# Construct URL other queries
else
query_values = {
- query: CGI::escape(data[:query])
+ :query => CGI::escape(data[:query])
}.merge(query_values)
uri.query_values = query_values
end
url = [Tmdb.base_api_url, method, data[:id], action].compact.join '/'
url_with_query = [url, uri.query].compact.join '?'
@@ -113,10 +114,10 @@
object.raw_data = data
["posters", "backdrops"].each do |image_array_name|
image_array = Array object.send(image_array_name)
single_name = image_array_name.slice 0..-2 # singularize name
single_path = object.send "#{single_name}_path" # default poster/backdrop image
- image_array << object.send("#{image_array_name.slice 0..-2}=", DeepOpenStruct.load({file_path: single_path}))
+ image_array << object.send("#{image_array_name.slice 0..-2}=", DeepOpenStruct.load({:file_path => single_path}))
# build a struct containing availables sizes with their urls
image_array.each do |image|
urls = CONFIGURATION.images.send("#{image_array_name}_sizes").inject({}) do |hash, size|
hash[size] = {'url' => [CONFIGURATION.images.base_url, size, image.file_path].join}
hash