Module: Grape::Formatter::SerializableHash

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

Class Method Summary collapse

Class Method Details

.call(object, env) ⇒ Object



5
6
7
8
9
10
# File 'lib/grape/formatter/serializable_hash.rb', line 5

def call(object, env)
  return object if object.is_a?(String)
  return MultiJson.dump(serialize(object)) if serializable?(object)
  return object.to_json if object.respond_to?(:to_json)
  MultiJson.dump(object)
end