mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 14:29:31 +00:00
25 lines
555 B
Ruby
25 lines
555 B
Ruby
module ActiveModel
|
|
class Serializer
|
|
class Adapter
|
|
extend ActiveSupport::Autoload
|
|
autoload :JsonAdapter
|
|
autoload :NullAdapter
|
|
autoload :JsonApiAdapter
|
|
|
|
attr_reader :serializer
|
|
|
|
def initialize(serializer)
|
|
@serializer = serializer
|
|
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
|