diff --git a/lib/movie_wrapper.rb b/lib/movie_wrapper.rb index ad85b9db..abac5d1c 100644 --- a/lib/movie_wrapper.rb +++ b/lib/movie_wrapper.rb @@ -23,16 +23,21 @@ def self.search(query) private def self.construct_movie(api_result) - Movie.new( + movie = Movie.new( title: api_result["title"], overview: api_result["overview"], release_date: api_result["release_date"], - image_url: api_result["poster_path"], #(api_result["poster_path"] ? self.construct_image_url(api_result["poster_path"]) : nil), + image_url: self.construct_image_url(api_result["poster_path"]), #(api_result["poster_path"] ? self.construct_image_url(api_result["poster_path"]) : nil), external_id: api_result["id"], ) + movie = movie.attributes + movie[:in_library] = Movie.find_by(external_id: api_result["id"]).is_a?(Movie) + return movie end def self.construct_image_url(img_name) - return BASE_IMG_URL + DEFAULT_IMG_SIZE + img_name + !img_name ? + DEFAULT_IMG_URL : + BASE_IMG_URL + DEFAULT_IMG_SIZE + img_name end end