class JSONApi::RelationshipSerializer::ToOneSerializer
Public Instance Methods
data_for(object, options)
click to toggle source
# File lib/json_api/relationship_serializer.rb, line 84 def data_for(object, options) return if options[:data] == false id = relationship_for(object, options) resource_identifier_for(type_for(object, options), id) end
key_for(**options)
click to toggle source
# File lib/json_api/relationship_serializer.rb, line 80 def key_for(**options) "#{super}_id" end
links_for(object, options)
click to toggle source
# File lib/json_api/relationship_serializer.rb, line 91 def links_for(object, options) return if options[:links] != true id = Utils.canonicalize_id(object.send(options[:id_attribute] || :id)) type = Utils.canonicalize_attribute_name(options[:name]) { related: "#{options[:base_url] || ""}/#{options[:parent_type]}/#{id}/#{type}" } end