Matthew Smillie
12/8/2005 12:54:00 AM
> Sorry I didn't get to this until this evening. Hope it's helpful. -T.
Noone's in a hurry over here, so no worries.
> module Flickr
> extend self
>
> @@api = {}
>
> def method_missing( sym , *args )
> @@api[sym] ||= Functor.new { |op, *args|
> api_call("#{sym}.#{op}", *args )
> }
> end
> end
Well, it helps (and that calibre library is quite cool), but: it
fails when there's more than three terms in the method, e.g.:
Flickr.photos.licenses.getInfo({"something" => "blah"})
undefined method `getInfo' for nil:NilClass (NoMethodError)
The general case (flickr.a.b...n), doesn't seem possible to me
without the object returned from #method_missing having the same
behaviour (i.e. implementation of #method_missing) as the initial
object, but with the previous calls as part of the object's state.
matt.