Class: Shamu::JsonApi::RelationshipBuilder

Inherits:
BaseBuilder
  • Object
show all
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

Methods included from BuilderMethods::Identifier

#compile

Methods inherited from BaseBuilder

#compile, #initialize

Methods included from BuilderMethods::Meta

#meta

Methods included from BuilderMethods::Link

#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.

Yields:

  • (builder)

Yield Parameters:



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