Class: Flickr
- Inherits:
-
Object
- Object
- Flickr
- Defined in:
- lib/flickr.rb
Defined Under Namespace
Classes: Tokens
Instance Method Summary collapse
- #api ⇒ Object
- #auth_token(auth_token) ⇒ Object
-
#initialize(api_key, shared_secret, auth_token = nil) ⇒ Flickr
constructor
A new instance of Flickr.
- #method_missing(method, *arguments, &block) ⇒ Object
Constructor Details
#initialize(api_key, shared_secret, auth_token = nil) ⇒ Flickr
Returns a new instance of Flickr.
4 5 6 7 |
# File 'lib/flickr.rb', line 4 def initialize(api_key, shared_secret, auth_token=nil) @tokens = Flickr::Tokens.new(api_key, shared_secret, auth_token) @api_request = FlickrApiRequest.new(@tokens) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/flickr.rb', line 29 def method_missing(method, *arguments, &block) if method.to_s =~ /^flickr_[\w]+/ self.class.send :define_method, method do |*arguments| if (arguments = arguments.flatten) != [] args = arguments[0][:args] auth = arguments[0][:auth] get = arguments[0][:get] end @api_request.call("#{method.to_s.gsub('_', '.')}", args || {}, (auth == nil ? false : auth), (get == nil ? true : get)) end self.send(method, arguments) else super end end |