Class: Banter::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/banter/middleware.rb

Constant Summary collapse

@@cached =
nil

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
# File 'lib/banter/middleware.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/banter/middleware.rb', line 10

def call(env)
  Banter::Context.clear!
  if @@cached.nil?
    @@cached = Banter::Configuration.batch_messages
  end
  if @@cached
    Banter.dedupe_messages { @app.call(env) }
  else
    @app.call(env)
  end
end