Class: Sinatra::SwaggerExposer::Processing::SwaggerProcessorDispatcher
- Inherits:
-
Object
- Object
- Sinatra::SwaggerExposer::Processing::SwaggerProcessorDispatcher
- Includes:
- SwaggerParameterHelper
- Defined in:
- lib/sinatra/swagger-exposer/processing/swagger-processor-dispatcher.rb
Overview
Dispatch content to a processor
Constant Summary
Constants included from SwaggerParameterHelper
SwaggerParameterHelper::HOW_TO_PASS, SwaggerParameterHelper::HOW_TO_PASS_BODY, SwaggerParameterHelper::HOW_TO_PASS_HEADER, SwaggerParameterHelper::HOW_TO_PASS_PATH, SwaggerParameterHelper::HOW_TO_PASS_QUERY, SwaggerParameterHelper::PARAMS_DEFAULT, SwaggerParameterHelper::PARAMS_EXAMPLE, SwaggerParameterHelper::PARAMS_EXCLUSIVE_MAXIMUM, SwaggerParameterHelper::PARAMS_EXCLUSIVE_MINIMUM, SwaggerParameterHelper::PARAMS_FORMAT, SwaggerParameterHelper::PARAMS_LIST, SwaggerParameterHelper::PARAMS_MAXIMUM, SwaggerParameterHelper::PARAMS_MAX_LENGTH, SwaggerParameterHelper::PARAMS_MINIMUM, SwaggerParameterHelper::PARAMS_MIN_LENGTH, SwaggerParameterHelper::PRIMITIVE_TYPES, SwaggerParameterHelper::PRIMITIVE_TYPES_FOR_NON_BODY, SwaggerParameterHelper::TYPE_ARRAY, SwaggerParameterHelper::TYPE_BOOLEAN, SwaggerParameterHelper::TYPE_BYTE, SwaggerParameterHelper::TYPE_DATE, SwaggerParameterHelper::TYPE_DATE_TIME, SwaggerParameterHelper::TYPE_DOUBLE, SwaggerParameterHelper::TYPE_FILE, SwaggerParameterHelper::TYPE_FLOAT, SwaggerParameterHelper::TYPE_INTEGER, SwaggerParameterHelper::TYPE_LONG, SwaggerParameterHelper::TYPE_NUMBER, SwaggerParameterHelper::TYPE_PASSWORD, SwaggerParameterHelper::TYPE_STRING
Instance Attribute Summary collapse
-
#how_to_pass ⇒ Object
readonly
Returns the value of attribute how_to_pass.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Instance Method Summary collapse
-
#initialize(how_to_pass, processor) ⇒ SwaggerProcessorDispatcher
constructor
Initialize.
-
#process(app, parsed_body) ⇒ Object
Process the value.
- #useful? ⇒ Boolean
Constructor Details
#initialize(how_to_pass, processor) ⇒ SwaggerProcessorDispatcher
Initialize
43 44 45 46 |
# File 'lib/sinatra/swagger-exposer/processing/swagger-processor-dispatcher.rb', line 43 def initialize(how_to_pass, processor) @how_to_pass = how_to_pass @processor = processor end |
Instance Attribute Details
#how_to_pass ⇒ Object (readonly)
Returns the value of attribute how_to_pass.
36 37 38 |
# File 'lib/sinatra/swagger-exposer/processing/swagger-processor-dispatcher.rb', line 36 def how_to_pass @how_to_pass end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
36 37 38 |
# File 'lib/sinatra/swagger-exposer/processing/swagger-processor-dispatcher.rb', line 36 def processor @processor end |
Instance Method Details
#process(app, parsed_body) ⇒ Object
Process the value
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sinatra/swagger-exposer/processing/swagger-processor-dispatcher.rb', line 53 def process(app, parsed_body) case @how_to_pass when HOW_TO_PASS_PATH # can't validate when HOW_TO_PASS_QUERY @processor.process(app.params) when HOW_TO_PASS_HEADER @processor.process(HashForHeaders.new(app)) when HOW_TO_PASS_BODY @processor.process(parsed_body || {}) end end |
#useful? ⇒ Boolean
48 49 50 |
# File 'lib/sinatra/swagger-exposer/processing/swagger-processor-dispatcher.rb', line 48 def useful? (@how_to_pass != HOW_TO_PASS_PATH) && @processor.useful? end |