Provide Rails url_helpers via SerializationContext

This commit is contained in:
Ben Mills
2016-03-01 19:23:55 -07:00
parent 3ba5254a46
commit cc10928472
15 changed files with 177 additions and 52 deletions

View File

@@ -20,9 +20,11 @@ module ActiveModel
# Define a link on a serializer.
# @example
# link :self { "//example.com/posts/#{object.id}" }
# link(:self) { resource_url(object) }
# @example
# link :self, "//example.com/user"
# link(:self) { "http://example.com/resource/#{object.id}" }
# @example
# link :resource, "http://example.com/resource"
#
def link(name, value = nil, &block)
_links[name] = block || value