class JSONApi::RelationshipSerializer::ToManySerializer
Public Instance Methods
data_for(object, options)
click to toggle source
# File lib/json_api/relationship_serializer.rb, line 61 def data_for(object, options) return if options[:data] != true ids = relationship_for(object, options) ids.map { |id| resource_identifier_for(type_for(object, options), id) } .compact end
key_for(**options)
click to toggle source
# File lib/json_api/relationship_serializer.rb, line 57 def key_for(**options) "#{super}_ids" end
links_for(object, options)
click to toggle source
# File lib/json_api/relationship_serializer.rb, line 69 def links_for(object, options) return if options[:links] == false 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