Class: Gitlab::Json::GrapeFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/json.rb

Overview

GrapeFormatter is a JSON formatter for the Grape API. This is set in lib/api/api.rb

Class Method Summary collapse

Class Method Details

.call(object, env = nil) ⇒ String

Convert an object to JSON.

This will default to the built-in Grape formatter if either :oj_json or :grape_gitlab_json flags are disabled.

The `env` param is ignored because it's not needed in either our formatter or Grape's, but it is passed through for consistency.

Parameters:

  • object (Object)

Returns:

  • (String)

191
192
193
194
195
196
197
# File 'lib/gitlab/json.rb', line 191

def self.call(object, env = nil)
  if Feature.enabled?(:grape_gitlab_json, default_enabled: true)
    Gitlab::Json.dump(object)
  else
    Grape::Formatter::Json.call(object, env)
  end
end