Module: ActionController::Serialization

Extended by:
ActiveSupport::Concern
Includes:
Renderers
Defined in:
lib/action_controller/serialization.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#get_serializer(resource, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/action_controller/serialization.rb', line 19

def get_serializer(resource, options = {})
  if !use_adapter?
    warn 'ActionController::Serialization#use_adapter? has been removed. '\
      "Please pass 'adapter: false' or see ActiveSupport::SerializableResource#serialize"
    options[:adapter] = false
  end
  ActiveModel::SerializableResource.serialize(resource, options) do |serializable_resource|
    if serializable_resource.serializer?
      serializable_resource.serialization_scope ||= serialization_scope
      serializable_resource.serialization_scope_name = _serialization_scope
      begin
        serializable_resource.adapter
      rescue ActiveModel::Serializer::ArraySerializer::NoSerializerError
        resource
      end
    else
      resource
    end
  end
end

#serialization_scopeObject



14
15
16
17
# File 'lib/action_controller/serialization.rb', line 14

def serialization_scope
  send(_serialization_scope) if _serialization_scope &&
    respond_to?(_serialization_scope, true)
end

#use_adapter?Boolean

Deprecated

Returns:

  • (Boolean)


41
42
43
# File 'lib/action_controller/serialization.rb', line 41

def use_adapter?
  true
end