Module: Shamu::JsonApi::BuilderMethods::Identifier

Included in:
RelationshipBuilder, ResourceBuilder
Defined in:
lib/shamu/json_api/builder_methods/identifier.rb

Instance Method Summary collapse

Instance Method Details

#compileHash

Returns the results output as JSON safe hash.

Returns:

  • (Hash)

    the results output as JSON safe hash.



24
25
26
27
# File 'lib/shamu/json_api/builder_methods/identifier.rb', line 24

def compile
  require_identifier!
  super
end

#identifier(type, id = :not_set) ⇒ self

Write a resource linkage info.

Parameters:

  • type (String)

    of the resource.

  • id (Object) (defaults to: :not_set)

    of the resource.

Returns:

  • (self)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shamu/json_api/builder_methods/identifier.rb', line 10

def identifier( type, id = :not_set )
  output[:type] = @type = json_type( type )

  output[:id] =
    if id == :not_set
      type.id if type.respond_to?( :id )
    else
      id.to_s
    end

  self
end