Class: Himari::Middlewares::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/himari/middlewares/config.rb

Constant Summary collapse

RACK_KEY =
'himari.config'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, kwargs = {}) ⇒ Config

Returns a new instance of Config.



8
9
10
11
# File 'lib/himari/middlewares/config.rb', line 8

def initialize(app, kwargs = {})
  @app = app
  @config = Himari::Config.new(**kwargs)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



13
14
15
# File 'lib/himari/middlewares/config.rb', line 13

def app
  @app
end

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/himari/middlewares/config.rb', line 13

def config
  @config
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/himari/middlewares/config.rb', line 15

def call(env)
  env[RACK_KEY] = config
  unless config.preserve_rack_logger
    env['rack.logger'] = config.logger
  end
  @app.call(env)
end