Class: Sinatra::SwaggerExposer::Processing::SwaggerFileProcessorDispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/swagger-exposer/processing/swagger-file-processor-dispatcher.rb

Overview

Fake dispatcher for files

Instance Method Summary collapse

Constructor Details

#initialize(name, required) ⇒ SwaggerFileProcessorDispatcher

Initialize

Parameters:

  • name (String)

    the name

  • required (TrueClass)

    if the parameter is required



15
16
17
18
# File 'lib/sinatra/swagger-exposer/processing/swagger-file-processor-dispatcher.rb', line 15

def initialize(name, required)
  @name = name
  @required = required
end

Instance Method Details

#process(app, parsed_body) ⇒ Object

Process the value



25
26
27
28
29
30
# File 'lib/sinatra/swagger-exposer/processing/swagger-file-processor-dispatcher.rb', line 25

def process(app, parsed_body)
  if app.params.key?(@name.to_s) && (!app.params[@name.to_s].nil?)
  elsif @required
    raise SwaggerInvalidException.new("Mandatory value [#{@name}] is missing")
  end
end

#useful?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/sinatra/swagger-exposer/processing/swagger-file-processor-dispatcher.rb', line 20

def useful?
  @required
end