Inline representers

22 views
Skip to first unread message

Rhett Sutphin

unread,
Aug 6, 2013, 11:01:26 AM8/6/13
to roar...@googlegroups.com
Hi,

I'm trying to get an inline representer working. I've got an small example
which I think is very similar to what's in the README, but I'm getting an
exception. The code is here:

https://gist.github.com/rsutphin/6165202

(This code just uses Representable, but my ultimate goal is to use this
with Roar. I hope it's okay to ask here.)

The full trace is in the gist also, but the short version is this:

lib/representable/binding.rb:139:in `serialize': undefined method
`to_hash' for #<struct Song title="Ana Ng", track=1> (NoMethodError)


Any suggestions about what I'm doing wrong? This looks like the same error
you get when you don't specify :extend on a collection, so it seems like
the inline representer just isn't being picked up.

There's a reported issue in Representable about inline decorators[1], but
not extend-type representers. If this is a bug (and not something that I'm
missing), I'll be happy to file it.

Thanks,
Rhett

[1]: https://github.com/apotonick/representable/issues/52


Rhett Sutphin

unread,
Aug 6, 2013, 11:15:23 AM8/6/13
to roar...@googlegroups.com
Hi,

Right after I posted this, I found the problem. It's that inline
representers don't work with collections because the block isn't passed
from Representable::ClassMethods::Declarations#property to #collection.
I'm putting together a patch.

Rhett
Reply all
Reply to author
Forward
0 new messages