Using decorators with lonely hashes?

26 views
Skip to first unread message

JP Slavinsky

unread,
Mar 3, 2014, 4:41:46 PM3/3/14
to roar...@googlegroups.com
Howdy - anyone know how to use decorators with lonely hashes?  

I see the example for using the module way of doing things, but not for decorators.  I have built up some infrastructure that is decorator-specific, and would like to continue using them.

Thanks! JP

JP Slavinsky

unread,
Mar 3, 2014, 4:57:33 PM3/3/14
to roar...@googlegroups.com
Didn't really figure this out.  But instead of using a simple hash, I used a Hashie::Mash which provides accessor methods for hash members.

outputs = ... call that returns a Hashie::Mash ...
respond_with outputs, represent_with: Api::V1::UserSearchRepresenter

Nick Sutterer

unread,
Mar 3, 2014, 5:06:43 PM3/3/14
to roar...@googlegroups.com
JP - I will add some tests for Decorator = Lonely Things. In the long term I wanna shift towards Decorators as a default.


--
You received this message because you are subscribed to the Google Groups "Roar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roar-talk+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

JP Slavinsky

unread,
Mar 3, 2014, 5:17:24 PM3/3/14
to roar...@googlegroups.com
thanks nick!
JP

You received this message because you are subscribed to a topic in the Google Groups "Roar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/roar-talk/E9gNEnbBAR4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to roar-talk+...@googlegroups.com.

Nick Sutterer

unread,
Mar 3, 2014, 9:59:58 PM3/3/14
to roar...@googlegroups.com
Lonely hashes with Decorator work exactly the same!

class LonesomeHash < Representable::Decorator
  include Representable::JSON::Hash

  values ...
end
Reply all
Reply to author
Forward
0 new messages