Module: Grape::Formatter::SerializableHash

Defined in:
lib/grape/formatter/serializable_hash.rb

Class Method Summary collapse

Class Method Details

.call(object, _env) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/grape/formatter/serializable_hash.rb', line 7

def call(object, _env)
  return object if object.is_a?(String)
  return ::Grape::Json.dump(serialize(object)) if serializable?(object)
  return object.to_json if object.respond_to?(:to_json)

  ::Grape::Json.dump(object)
end