The Embeddable base class should not be instantiated directly. It provides common functionality for Hoodoo::Presenters::Embedding::Embeds and Hoodoo::Presenters::Embedding::References - use those instead.
Create an instance.
Source: show
# File lib/hoodoo/presenters/embedding.rb, line 29 def initialize @hash = {} end
Add a collection of resources (for embedding) or UUIDs (for referencing) to an embed or reference assembly.
key
-
The key to use in the resource representation leading to the embedded resource object or UUID string array. Typically follows a plural name convention in your resource API field language of choice, e.g. “members” (an API where the resource names and fields are in English), “mitglieder” (an API described in German).
This key must match the value specified in the query string of a request in order to ask for the things in question to be embedded / referenced.
array_of_rendered_resources_or_uuids
-
An Array of rendered resource representations in full, or an Array of resource UUID Strings.
Source: show
# File lib/hoodoo/presenters/embedding.rb, line 73 def add_many( key, array_of_rendered_resources_or_uuids ) validate_many( array_of_rendered_resources_or_uuids ) @hash[ key ] = array_of_rendered_resources_or_uuids end
Add a singlular resource (for embedding) or UUID (for referencing) to an embed or reference assembly.
key
-
The key to use in the resource representation leading to the embedded resource object or UUID string. Typically follows a singular name convention in your resource API field language of choice, e.g. “member” (an API where the resource names and fields are in English), “mitglied” (an API described in German).
This key must match the value specified in the query string of a request in order to ask for the thing in question to be embedded / referenced.
rendered_resource_or_uuid
-
A rendered resource representation in full, or a resource UUID String.
Source: show
# File lib/hoodoo/presenters/embedding.rb, line 50 def add_one( key, rendered_resource_or_uuid ) validate_one( rendered_resource_or_uuid ) @hash[ key ] = rendered_resource_or_uuid end
Delete all data associated with the given key.
Source: show
# File lib/hoodoo/presenters/embedding.rb, line 84 def remove( key ) @hash.delete( key ) end
Returns a Hash where keys are the keys provided in calls to add_one or add_many and values are the values provided to those same corresponding calls. Returns an empty Hash if no such calls have been made or if all the keys were subsequently removed with remove.
Source: show
# File lib/hoodoo/presenters/embedding.rb, line 93 def retrieve @hash end