Class: WhenAUser::Rack

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

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Rack

Returns a new instance of Rack.



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/whenauser.rb', line 92

def initialize(app, options={})
  @app = app
  WhenAUser.logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
  WhenAUser.webhook_url = options[:webhook_url] || 'http://www.whenauser.com/events/'
  WhenAUser.buffer = []
  WhenAUser.filter_parameters = defined?(Rails) ? Rails.application.config.filter_parameters : []
  WhenAUser.token = options[:token]
  WhenAUser.queue = options[:queue] || WhenAUser::MemoryQueue
  WhenAUser.queue_options = options[:queue_options] || {}
  WhenAUser.controller_data = options[:controller_data] || '{}'
end

Instance Method Details

#call(env) ⇒ Object



104
105
106
107
108
109
# File 'lib/whenauser.rb', line 104

def call(env)
  WhenAUser.buffer = []
  @app.call(env)
ensure
  WhenAUser.flush(env)
end