Class: Leif::CollectionJson::Collection
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Leif::CollectionJson::Collection
- Extended by:
- Forwardable
- Includes:
- Linked
- Defined in:
- lib/leif/collection_json.rb
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(body) ⇒ Collection
constructor
A new instance of Collection.
- #item_template(item) ⇒ Object
- #items ⇒ Object
- #template(href = fetch('href'), method = :post) ⇒ Object
Methods included from Linked
#link_href, #link_relations, #links
Constructor Details
#initialize(body) ⇒ Collection
Returns a new instance of Collection.
25 26 27 |
# File 'lib/leif/collection_json.rb', line 25 def initialize(body) super body.fetch('collection') end |
Instance Method Details
#item_template(item) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/leif/collection_json.rb', line 38 def item_template(item) template = template(item.fetch('href'), :put) item.fetch('data').inject(template) {|template, datum| template.fill_field datum.fetch('name'), datum.fetch('value') } end |