Class: Metaphor::Processor::JsonProcessor
- Inherits:
-
Object
- Object
- Metaphor::Processor::JsonProcessor
- Defined in:
- lib/metaphor/processor/json_processor.rb
Instance Method Summary collapse
- #call(headers, body) ⇒ Object
-
#initialize ⇒ JsonProcessor
constructor
A new instance of JsonProcessor.
Constructor Details
#initialize ⇒ JsonProcessor
Returns a new instance of JsonProcessor.
4 5 6 |
# File 'lib/metaphor/processor/json_processor.rb', line 4 def initialize require 'json' end |
Instance Method Details
#call(headers, body) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/metaphor/processor/json_processor.rb', line 8 def call(headers, body) result = JSON[body] headers['content-type'] = case result when Hash 'application/x-ruby' when String 'application/json' end [ headers, result ] end |