Hi Everyone,
I'm working on a gem that interacts with an API (smugmug.com, if you care)
and I'm running into an issue.
The API requires that you make an initial request with a username and
password to receive a session_id. Subsequent requests just use the
session_id. Fine, no big deal:
> smug = Smirk::Client.new("username", "password")
> smug.session_id
=> "my_valid_session_id"
> smug.albums.map(&:title).join(", ")
=> "Trees, Mountains, Yada Yada"
albums is a method on the Client class that grabs all albums in that account
and instantiates each as an Album object -- session_id is an ivar in Client,
so no problem there. If I want to make any additional API calls from within
the Album class, I need that session_id. Is the best (or only) way to
initialize an Album object with the session_id? It's equally annoying when
I want all images within an Album, as I need to pass that session id over to
the new Image objects as well.
Relevant files are here if you want to see where it's at now:
http://github.com/bensie/smirk/blob/master/lib/smirk/client.rb
http://github.com/bensie/smirk/blob/master/lib/smirk/album.rb
http://github.com/bensie/smirk/blob/master/lib/smirk/image.rb
Thanks everyone,
James
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby