Class: Rack::AdequateJson
- Inherits:
-
Object
- Object
- Rack::AdequateJson
- Defined in:
- lib/rack/adequate_json/version.rb,
lib/rack/adequate_json/adequate_json.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#target_param ⇒ Object
readonly
Returns the value of attribute target_param.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AdequateJson
constructor
A new instance of AdequateJson.
Constructor Details
#initialize(app, options = {}) ⇒ AdequateJson
Returns a new instance of AdequateJson.
5 6 7 8 9 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 5 def initialize(app , ={}) @app = app @root = .fetch(:root, nil) @target_param = .fetch(:target_param, "fields") end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
3 4 5 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 3 def app @app end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 3 def headers @headers end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
3 4 5 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 3 def root @root end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 3 def status @status end |
#target_param ⇒ Object (readonly)
Returns the value of attribute target_param.
3 4 5 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 3 def target_param @target_param end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rack/adequate_json/adequate_json.rb', line 11 def call(env) call_and_setup(env) if content_type_json? && filter_fields [ status, headers, response_stream { |b| filter_json_body(b) } ] else [status, headers, response_stream] end end |