Class: Gitlab::Json::GrapeFormatter
- Inherits:
-
Object
- Object
- Gitlab::Json::GrapeFormatter
- 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
-
.call(object, env = nil) ⇒ String
Convert an object to JSON.
Class Method Details
.call(object, env = nil) ⇒ String
Convert an object to JSON.
The ‘env` param is ignored because it’s not needed in either our formatter or Grape’s, but it is passed through for consistency.
If explicitly supplied with a ‘PrecompiledJson` instance it will skip conversion and return it directly. This is mostly used in caching.
191 192 193 194 195 |
# File 'lib/gitlab/json.rb', line 191 def self.call(object, env = nil) return object.to_s if object.is_a?(PrecompiledJson) Gitlab::Json.dump(object) end |