class ActiveModel::Serializer
def self.link(name, *args, &block)
link(:callback, if: :internal?), { "http://example.com/callback" }
@example
link :resource, "http://example.com/resource"
@example
link(:self) { "http://example.com/resource/#{object.id}" }
@example
link(:self) { resource_url(object) }
@example
Define a link on a serializer.
def self.link(name, *args, &block) options = args.extract_options! # For compatibility with the use case of passing link directly as string argument # without block, we are creating a wrapping block _links[name] = Link.new(name, options, block || ->(_serializer) { args.first }) end