mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge pull request #1322 from bf4/maurogeorge-patch-10
Instrumenting rendering of resources
This commit is contained in:
@@ -2,6 +2,12 @@ require 'set'
|
||||
module ActiveModel
|
||||
class SerializableResource
|
||||
ADAPTER_OPTION_KEYS = Set.new([:include, :fields, :adapter, :meta, :meta_key, :links])
|
||||
include ActiveModelSerializers::Logging
|
||||
|
||||
delegate :serializable_hash, :as_json, :to_json, to: :adapter
|
||||
notify :serializable_hash, :render
|
||||
notify :as_json, :render
|
||||
notify :to_json, :render
|
||||
|
||||
# Primary interface to composing a resource with a serializer and adapter.
|
||||
# @return the serializable_resource, ready for #as_json/#to_json/#serializable_hash.
|
||||
@@ -11,8 +17,6 @@ module ActiveModel
|
||||
options.partition { |k, _| ADAPTER_OPTION_KEYS.include? k }.map { |h| Hash[h] }
|
||||
end
|
||||
|
||||
delegate :serializable_hash, :as_json, :to_json, to: :adapter
|
||||
|
||||
def serialization_scope=(scope)
|
||||
serializer_opts[:scope] = scope
|
||||
end
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
require 'rails/railtie'
|
||||
|
||||
module ActiveModel
|
||||
class Railtie < Rails::Railtie
|
||||
initializer 'active_model_serializers.logger' do
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
ActiveModelSerializers.logger = ActionController::Base.logger
|
||||
ActiveSupport.on_load(:active_model_serializers) do
|
||||
self.logger = ActionController::Base.logger
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user