class ActiveModel::Serializer

def build_json(controller, resource, options)

not be manually defined for this method.
set during the request lifecycle or by the controller class, and should
settings and options for a given resource. These settings are typically
Used internally to create a new serializer object based on controller
def build_json(controller, resource, options)
  default_options = controller.send(:default_serializer_options) || {}
  options = default_options.merge(options || {})
  serializer = options.delete(:serializer) ||
    (resource.respond_to?(:active_model_serializer) &&
     resource.active_model_serializer)
  return serializer unless serializer
  if resource.respond_to?(:to_ary)
    unless serializer <= ActiveModel::ArraySerializer
      raise ArgumentError.new("#{serializer.name} is not an ArraySerializer. " +
                              "You may want to use the :each_serializer option instead.")
    end
    if options[:root] != false && serializer.root != false
      # the serializer for an Array is ActiveModel::ArraySerializer
      options[:root] ||= serializer.root || controller.controller_name
    end
  end
  options[:scope] = controller.serialization_scope unless options.has_key?(:scope)
  options[:scope_name] = controller._serialization_scope
  options[:url_options] = controller.url_options
  serializer.new(resource, options)
end