Class: Jsonify
- Inherits:
-
Object
- Object
- Jsonify
- Defined in:
- lib/jsonify.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(route, model) ⇒ Jsonify
constructor
A new instance of Jsonify.
Constructor Details
#initialize(route, model) ⇒ Jsonify
Returns a new instance of Jsonify.
2 3 4 5 |
# File 'lib/jsonify.rb', line 2 def initialize(route, model) @route = route @model = model end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/jsonify.rb', line 7 def call(env) path = env['REQUEST_PATH'] response = path == @route ? all : one(find_id(path)) header = @model.http_cache_header.merge("Content-Type" => "application/json") [200, header, [response]] end |