Class: RackFlags::RackMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-flags/rack_middleware.rb

Constant Summary collapse

ENV_KEY =
'x-rack-flags.flag-reader'

Instance Method Summary collapse

Constructor Details

#initialize(app, args) ⇒ RackMiddleware

Returns a new instance of RackMiddleware.



5
6
7
8
9
# File 'lib/rack-flags/rack_middleware.rb', line 5

def initialize( app, args )
  @app = app
  @disable_config_caching = args.fetch(:disable_config_caching, false)
  @yaml_path = args.fetch( :yaml_path ){ raise ArgumentError.new( 'yaml_path must be provided' ) }
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rack-flags/rack_middleware.rb', line 11

def call( env )
  overrides = CookieCodec.new.overrides_from_env( env )
  reader = Reader.new( config.flags, overrides )
  env[ENV_KEY] = reader

  @app.call(env)
end