mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
The options passed to the render are partitioned into adapter options and serializer options. 'include' and 'root' are sent to the adapter, not sure what options would go directly to serializer, but leaving this in until I understand that better.
26 lines
577 B
Ruby
26 lines
577 B
Ruby
module ActiveModel
|
|
class Serializer
|
|
class Adapter
|
|
extend ActiveSupport::Autoload
|
|
autoload :Json
|
|
autoload :Null
|
|
autoload :JsonApi
|
|
|
|
attr_reader :serializer
|
|
|
|
def initialize(serializer, options = {})
|
|
@serializer = serializer
|
|
@options = options
|
|
end
|
|
|
|
def serializable_hash(options = {})
|
|
raise NotImplementedError, 'This is an abstract method. Should be implemented at the concrete adapter.'
|
|
end
|
|
|
|
def to_json(options = {})
|
|
serializable_hash(options).to_json
|
|
end
|
|
end
|
|
end
|
|
end
|