Class: Shamu::JsonApi::RelationshipBuilder
- Inherits:
-
BaseBuilder
- Object
- BaseBuilder
- Shamu::JsonApi::RelationshipBuilder
- Includes:
- BuilderMethods::Identifier
- Defined in:
- lib/shamu/json_api/relationship_builder.rb
Overview
Build a relationship from one resource to another.
Instance Method Summary collapse
-
#identifier(type, id = nil)
Write a resource linkage info.
-
#include_resource(resource, presenter = nil) {|builder| ... } ⇒ Object
Add an included resource for a compound response.
Methods included from BuilderMethods::Identifier
Methods inherited from BaseBuilder
Methods included from BuilderMethods::Meta
Methods included from BuilderMethods::Link
Constructor Details
This class inherits a constructor from Shamu::JsonApi::BaseBuilder
Instance Method Details
#identifier(type, id = nil)
This method returns an undefined value.
Write a resource linkage info.
22 23 24 25 26 27 |
# File 'lib/shamu/json_api/relationship_builder.rb', line 22 def identifier( type, id = nil ) output[:data] ||= {} output[:data][:type] = @type = type.to_s output[:data][:id] = id.to_s self end |
#include_resource(resource, presenter = nil) {|builder| ... } ⇒ Object
Add an included resource for a compound response.
If no presenter
and no block are provided a default presenter will be
obtained by calling #find_presenter.
11 12 13 |
# File 'lib/shamu/json_api/relationship_builder.rb', line 11 def include_resource( resource, presenter = nil, &block ) context.include_resource resource, presenter, &block end |