Method: Hanami::API::Block::Context#json
- Defined in:
- lib/hanami/api/block/context.rb
#json(object, mime = "application/json") ⇒ Object
Sets a JSON response for the given object
125 126 127 128 129 130 131 132 133 |
# File 'lib/hanami/api/block/context.rb', line 125 def json(object, mime = "application/json") headers["Content-Type"] = mime case object in Enumerator => collection json_enum(collection) else JSON.generate(object) end end |