Class: Hoodoo::Presenters::Embedding::Embeds
- Inherits:
-
Embeddable
- Object
- Embeddable
- Hoodoo::Presenters::Embedding::Embeds
- Defined in:
- lib/hoodoo/presenters/embedding.rb
Overview
Instantiate this class and add one, or an Array of fully rendered resource objects to it via the API described in the base class, Hoodoo::Presenters::Embedding::Embeddable. You can then pass it to the likes of Hoodoo::Presenters::Base.render_in via the options
parameter to have the embed data included in the fully rendered end result.
When a request arrives to embed data for a particular resource or list of resources (in which case, do the following for each item in that list):
-
Render the embedded resource(s)
-
Create an instance of this class
-
Add the rendered resource representations using this class’s API
-
Use Hoodoo::Presenters::Base.render_in to render the final, target resource, passing in the embed collection via the
options
Hash.
Simple example:
= Hoodoo::Presenters::Embedding::Embeds.new
.add_one( 'balance', rendered_balance )
.add_many( 'vouchers', rendered_voucher_array )
Instance Method Summary collapse
-
#resource_key ⇒ Object
Returns the top-level resource key used for reference data, as per the API documentation - which is the String
_embed
.
Methods inherited from Embeddable
#add_many, #add_one, #initialize, #remove, #retrieve
Constructor Details
This class inherits a constructor from Hoodoo::Presenters::Embedding::Embeddable
Instance Method Details
#resource_key ⇒ Object
Returns the top-level resource key used for reference data, as per the API documentation - which is the String _embed
.
128 129 130 |
# File 'lib/hoodoo/presenters/embedding.rb', line 128 def resource_key '_embed' end |