Class: Routemaster::Middleware::Filter
- Inherits:
-
Object
- Object
- Routemaster::Middleware::Filter
- Defined in:
- lib/routemaster/middleware/filter.rb
Overview
Filters event payloads passed in the environment (in
env['routemaster.payload']
), is any.
Will use Routemaster::Dirty::Filter
by default.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Filter
constructor
options[:filter] [Routemaster::Dirty::Filter] an event filter (optional; will be created using the
redis
andexpiry
options if not provided).
Constructor Details
#initialize(app, options = {}) ⇒ Filter
options[:filter] [Routemaster::Dirty::Filter] an event filter (optional;
will be created using the redis
and expiry
options if not provided)
12 13 14 15 |
# File 'lib/routemaster/middleware/filter.rb', line 12 def initialize(app, = {}) @app = app @filter = .fetch(:filter) { Routemaster::Dirty::Filter.new } end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/routemaster/middleware/filter.rb', line 17 def call(env) payload = env['routemaster.payload'] if payload && payload.any? env['routemaster.payload'] = @filter.run(payload) end @app.call(env) end |