Send property outbound, don't allow it to be set inbound

5 views
Skip to first unread message

JP Slavinsky

unread,
Nov 28, 2013, 9:54:44 AM11/28/13
to roar...@googlegroups.com
Howdy --

There are some fields that I want to expose in my API's read-only calls (GETs), but that I don't want to be settable via my API, e.g. the "id" field of my records.

Is the proper way to handle this to set a "null" setter on a property, as in:

module Api::V1
  class ContentRepresenter < Roar::Decorator
    include Roar::Representer::JSON

    property :id, setter: lambda {|*|}
    property :markup
    property :html

  end
end

?

Seems to work, just don't know if there's a better way.

Thanks, JP

Andrés Freyría

unread,
Nov 28, 2013, 11:36:23 AM11/28/13
to roar...@googlegroups.com
Since roar builds on top of representable, there's a lot of features that you can find over there. A bit confusing, I know, but I hear Nick is rewriting the README ;)

Cheers,


Andrés Freyría Cedeño


2013/11/28 JP Slavinsky <j...@kindlinglabs.com>

--
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,
Nov 28, 2013, 11:58:57 AM11/28/13
to roar...@googlegroups.com, roar...@googlegroups.com
Time to study the representable readme!  Thanks Andres!
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/hgAf7RfvwWs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to roar-talk+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages