module ActionController::Serialization

def _render_option_json(resource, options)

def _render_option_json(resource, options)
  serializer = build_json_serializer(resource, options)
  if serializer
    super(serializer, options)
  else
    super
  end
end

def build_json_serializer(resource, options = {})

def build_json_serializer(resource, options = {})
  options = default_serializer_options.merge(options)
  if serializer = options.fetch(:serializer, ActiveModel::Serializer.serializer_for(resource))
    options[:scope] = serialization_scope unless options.has_key?(:scope)
    options[:resource_name] = controller_name if resource.respond_to?(:to_ary)
    serializer.new(resource, options)
  end
end

def default_serializer_options

def default_serializer_options
  {}
end

def serialization_scope

def serialization_scope
  _serialization_scope = self.class._serialization_scope
  send(_serialization_scope) if _serialization_scope && respond_to?(_serialization_scope, true)
end