Class: JSONAPI::Consumer::Associations::BelongsTo::Association

Inherits:
JSONAPI::Consumer::Associations::BaseAssociation show all
Includes:
Helpers::URI
Defined in:
lib/jsonapi/consumer/associations/belongs_to.rb

Instance Attribute Summary

Attributes inherited from JSONAPI::Consumer::Associations::BaseAssociation

#attr_name, #klass, #options

Instance Method Summary collapse

Methods included from Helpers::URI

#encode_part

Methods inherited from JSONAPI::Consumer::Associations::BaseAssociation

#association_class, #data, #from_result_set, #initialize

Constructor Details

This class inherits a constructor from JSONAPI::Consumer::Associations::BaseAssociation

Instance Method Details

#paramObject



15
16
17
# File 'lib/jsonapi/consumer/associations/belongs_to.rb', line 15

def param
  :"#{attr_name}_id"
end

#set_prefix_path(attrs, formatter) ⇒ Object



23
24
25
26
# File 'lib/jsonapi/consumer/associations/belongs_to.rb', line 23

def set_prefix_path(attrs, formatter)
  attrs[param] = encode_part(attrs[param]) if attrs.key?(param)
  to_prefix_path(formatter) % attrs
end

#to_prefix_path(formatter) ⇒ Object



19
20
21
# File 'lib/jsonapi/consumer/associations/belongs_to.rb', line 19

def to_prefix_path(formatter)
  "#{formatter.format(attr_name.to_s.pluralize)}/%{#{param}}"
end