Class: Storey::RackSwitch

Inherits:
Object
  • Object
show all
Defined in:
lib/storey/rack_switch.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, processor = Storey.configuration.switch_processor) ⇒ RackSwitch

Returns a new instance of RackSwitch.



4
5
6
# File 'lib/storey/rack_switch.rb', line 4

def initialize(app, processor=Storey.configuration.switch_processor)
  @app, @processor = app, processor
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/storey/rack_switch.rb', line 8

def call(env)
  schema = @processor.call(env)

  if schema
    Storey.switch(schema) { @app.call(env) }
  else
    @app.call(env)
  end
end