Class: Hoodoo::Presenters::Embedding::References

Inherits:
Embeddable
  • Object
show all
Defined in:
lib/hoodoo/presenters/embedding.rb

Overview

Instantiate this class and add one, or an Array of UUID strings 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 reference data included in the fully rendered end result.

When a request arrives to reference UUID data for a particular resource or list of resources (in which case, do the following for each item in that list):

  • Obtain the referenced resource UUID(s)

  • Create an instance of this class

  • Add the UUIDs using this class’s API

  • Use Hoodoo::Presenters::Base.render_in to render the final, target resource, passing in the reference collection via the options Hash.

Simple example:

references = Hoodoo::Presenters::Embedding::References.new
references.add_one( 'member', member_uuid )
references.add_many( 'memberships', array_of_membership_uuids )

Instance Method Summary collapse

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_keyObject

Returns the top-level resource key used for reference data, as per the API documentation - which is the String _reference.



194
195
196
# File 'lib/hoodoo/presenters/embedding.rb', line 194

def resource_key
  '_reference'
end