mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Breaking change: - Adapters now inherit Adapter::Base - 'Adapter' is now a module, no longer a class Why? - using a class as a namespace that you also inherit from is complicated and circular at time i.e. buggy (see https://github.com/rails-api/active_model_serializers/pull/1177) - The class methods on Adapter aren't necessarily related to the instance methods, they're more Adapter functions - named `Base` because it's a Rails-ism - It helps to isolate and highlight what the Adapter interface actually is
22 lines
539 B
Ruby
22 lines
539 B
Ruby
module ActiveModel
|
|
class Serializer
|
|
module Adapter
|
|
class Json < Base
|
|
extend ActiveSupport::Autoload
|
|
autoload :FragmentCache
|
|
|
|
def serializable_hash(options = nil)
|
|
options ||= {}
|
|
{ root => Attributes.new(serializer).serializable_hash(options) }
|
|
end
|
|
|
|
private
|
|
|
|
def fragment_cache(cached_hash, non_cached_hash)
|
|
ActiveModel::Serializer::Adapter::Json::FragmentCache.new.fragment_cache(cached_hash, non_cached_hash)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|