module Shamu::JsonApi::BuilderMethods::Identifier
Attributes
type[R]
Public Instance Methods
compile()
click to toggle source
(see BaseBuilder#compile
)
Calls superclass method
# File lib/shamu/json_api/builder_methods/identifier.rb, line 24 def compile require_identifier! super end
identifier( type, id = :not_set )
click to toggle source
Write a resource linkage info.
@param [String] type of the resource. @param [Object] id of the resource. @return [self]
# 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
Private Instance Methods
json_type( type )
click to toggle source
# File lib/shamu/json_api/builder_methods/identifier.rb, line 33 def json_type( type ) type = type.json_type if type.respond_to?( :json_type ) type = type.model_name.element if type.respond_to?( :model_name ) type = type.name.demodulize.underscore if type.is_a?( Module ) type.to_s end
require_identifier!()
click to toggle source
# File lib/shamu/json_api/builder_methods/identifier.rb, line 41 def require_identifier! fail IncompleteResourceError unless type end