saasbook

movie.3.rb

Sep 15th, 2014
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.41 KB | None | 0 0
  1. class Movie < ActiveRecord::Base
  2.  
  3.   class Movie::InvalidKeyError < StandardError ; end
  4.  
  5.   def self.find_in_tmdb(string)
  6.     begin
  7.       Tmdb::Movie.find(string)
  8.     rescue NoMethodError => tmdb_gem_exception
  9.       if Tmdb::Api.response['code'] == 401
  10.         raise Movie::InvalidKeyError, 'Invalid API key'
  11.       else
  12.         raise tmdb_gem_exception
  13.       end
  14.     end
  15.   end
  16.  
  17.   # rest of file elided for brevity
  18. end
Add Comment
Please, Sign In to add comment