Module: Roar::Representer::JSON::CollectionJSON
- Defined in:
- lib/roar/representer/json/collection_json.rb
Overview
Implementation of the Collection+JSON media format, amundsen.com/media-types/collection/format/
When clients want to add or update an item the collection’s filled out template is POSTed or PUT. You can parse that using the SongCollectionRepresenter::template_representer
module.
Song.new.extend(SongCollectionRepresenter.template_representer).from_json("{template: ...")
Defined Under Namespace
Modules: ClassMethods, ClientMethods, DataMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/roar/representer/json/collection_json.rb', line 9 def self.included(base) base.class_eval do include Roar::Representer include Roar::Representer::JSON include Roar::Representer::Feature::Hypermedia extend ClassMethods self.representation_wrap= :collection # FIXME: move outside of this block for inheritance! property :__template, :as => :template, :extend => lambda {|*| representable_attrs.collection_representers[:template] }, :class => Array def __template OpenStruct.new # TODO: handle preset values. end collection :queries, :extend => Roar::Representer::JSON::HyperlinkRepresenter def queries compile_links_for(representable_attrs.collection_representers[:queries].link_configs) end def queries=(v) end def items self end def items=(v) replace(v) end property :__version, :as => :version def __version representable_attrs.collection_representers[:version] end property :__href, :as => :href def __href compile_links_for(representable_attrs.collection_representers[:href].link_configs).first.href end include ClientMethods end end |