Ruby objects instead of raw Json

164 views
Skip to first unread message

waseem ahmad

unread,
Jun 1, 2010, 8:43:41 AM6/1/10
to koala...@googlegroups.com
Hi,

I am using facebooker in my Rails application. Right now I am considering to upgrade to the new Open Graph API. I considered all the available options(Mogli, Rest-Graph and Koala) and decided to use koala in my application. The main decisive factor is that koala, a single gem, provides support to both the REST API and also the Graph API.

However, I do not like one thing about koala. When a request is made to the facebook servers, koala returns plain Json after converting it into a Ruby hash as response. Shouldn't it return Ruby objects? Like a User object when a  rest.get_object("me") request is made.

Having Ruby objects instead of simple hashes, we could extend these objects later on and add some custom methods to them also.

If you/we are not going to do this, can someone suggest me how to do this in koala. I will fork away and start implementing.

Thanks!

--
Waseem
Blog: http://babygnu.blogspot.com
Twitter: http://twitter.com/_waseem

Chris Baclig

unread,
Jun 1, 2010, 3:42:41 PM6/1/10
to Koala & The Facebook Graph API
One of the goals of Koala is to be as lightweight as Facebook's own
official libraries (i.e. PHP SDK, Python SDK) so all of the calls (for
the most part) return the raw data from Facebook in an easily
consumable interface (in Ruby's case, hashes.) A lot of the GraphAPI
module methods actually mimic methods in those libraries.

I'm tempted to say that object wrappers for each type of object isn't
necessarily on the road map for Koala at this point. This would
detract from the lightness of the library for users who, for example,
only need to access user objects but have to additionally download
class files for all of the other types of objects in the graph.

That being said, there are cases where having Ruby objects for nodes
in the graph would be useful, as you pointed out. Instead of a fork,
I would suggest building a library on top of Koala so that, as the
object library matures, it could be offered as a Koala plug-in/add-
on. Basically, a distinct gem that would just require the koala gem.
This way, those who don't want/need the objects can just use the Koala
gem, while those who want more, could additionally install this new
gem as well. I haven't thought through it all the way, but it seems
like that would be a nice way to keep this new library more resilient
from Koala core changes.


Chris

John McGrath

unread,
Jun 1, 2010, 4:36:14 PM6/1/10
to koala...@googlegroups.com
Chris, I'm glad to hear that keeping koala lightweight is a goal--it's one of the most attractive things about it, in my opinion. We just used Koala to switch Wordnik (http://www.wordnik.com) over to the GraphAPI, and it was impressively simple. We had no problem using the returned hashes directly.

For those who need object wrappers, adding a separate gem or rolling your own layer strikes me as a better option than weighing down the core gem.

Thanks for your work on Koala, it's much appreciated :-)


--
You received this message because you are subscribed to the Google Groups "Koala & The Facebook Graph API" group.
To post to this group, send email to koala...@googlegroups.com.
To unsubscribe from this group, send email to koala-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/koala-users?hl=en.




--
John McGrath
jo...@wordnik.com
http://www.wordnik.com
twitter: Wordie
(207) 332-8709

Alex K

unread,
Jun 1, 2010, 5:51:50 PM6/1/10
to Koala & The Facebook Graph API
Waseem, let us know if you're interested in building a library on top
of Koala. It's a great idea, and we'd be happy to help with
coordination and promotion.

John, thanks for the positive feedback :)

Alex

On Jun 1, 1:36 pm, John McGrath <j...@wordnik.com> wrote:
> Chris, I'm glad to hear that keeping koala lightweight is a goal--it's one
> of the most attractive things about it, in my opinion. We just used Koala to
> switch Wordnik (http://www.wordnik.com) over to the GraphAPI, and it was
> impressively simple. We had no problem using the returned hashes directly.
>
> For those who need object wrappers, adding a separate gem or rolling your
> own layer strikes me as a better option than weighing down the core gem.
>
> Thanks for your work on Koala, it's much appreciated :-)
>
> > koala-users...@googlegroups.com<koala-users%2Bunsubscribe@googlegr oups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/koala-users?hl=en.
>
> --
> John McGrath
> j...@wordnik.comhttp://www.wordnik.com
> twitter: Wordie
> (207) 332-8709

waseem ahmad

unread,
Jun 22, 2010, 1:50:57 PM6/22/10
to koala...@googlegroups.com
Hi,

I have been working on joey[1] from some time now. It is a library written on top of Koala which provides Ruby object wrappers for nodes in the Graph API. Check it out!

[1]: http://github.com/waseem/Joey

To unsubscribe from this group, send email to koala-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/koala-users?hl=en.




--
Reply all
Reply to author
Forward
0 new messages