Class: Sparrow::Strategies::RawInput
- Inherits:
-
Object
- Object
- Sparrow::Strategies::RawInput
- Includes:
- Transformable
- Defined in:
- lib/sparrow/strategies/raw_input.rb
Overview
Handles plain JSON input parameter conversion which is sent via env
Instance Attribute Summary collapse
-
#env ⇒ Hash
readonly
The Rack environment.
-
#type ⇒ Symbol
readonly
The HTTP message type.
Class Method Summary collapse
-
.handle(env, type) ⇒ Hash
Do the transformation.
Instance Method Summary collapse
-
#handle ⇒ Hash
Starts the conversion.
-
#initialize(env, type = :request, params = nil) ⇒ RawInput
constructor
Create a new RawInput Strategy.
-
#params ⇒ Hash
The parameters to be transformed.
Methods included from Transformable
Constructor Details
#initialize(env, type = :request, params = nil) ⇒ RawInput
Create a new RawInput Strategy
29 30 31 32 33 |
# File 'lib/sparrow/strategies/raw_input.rb', line 29 def initialize(env, type = :request, params = nil) @env = env || {} @params = params @type = type end |
Instance Attribute Details
#env ⇒ Hash (readonly)
Returns the Rack environment.
11 12 13 |
# File 'lib/sparrow/strategies/raw_input.rb', line 11 def env @env end |
#type ⇒ Symbol (readonly)
Returns the HTTP message type.
14 15 16 |
# File 'lib/sparrow/strategies/raw_input.rb', line 14 def type @type end |
Class Method Details
.handle(env, type) ⇒ Hash
Do the transformation
19 20 21 |
# File 'lib/sparrow/strategies/raw_input.rb', line 19 def self.handle(env, type) self.new(env, type).handle end |
Instance Method Details
#handle ⇒ Hash
Starts the conversion
38 39 40 41 |
# File 'lib/sparrow/strategies/raw_input.rb', line 38 def handle super handle_raw_rack end |
#params ⇒ Hash
The parameters to be transformed
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sparrow/strategies/raw_input.rb', line 47 def params if @params @params else input_io = @env[HttpMessage::RACK_INPUT_KEY] params = input_io.send(:read) input_io.rewind params end end |