Class: RulesIO::Users

Inherits:
Rack show all
Includes:
Helpers
Defined in:
lib/rulesio/users.rb

Direct Known Subclasses

Exceptions

Instance Attribute Summary

Attributes inherited from Rack

#config_options, #controller_data, #filter_parameters

Attributes inherited from Base

#buffer, #token

Instance Method Summary collapse

Methods included from Helpers

#actor_for_exception, #clean_backtrace, #fileline, #from_crawler

Methods inherited from Rack

config_options, config_options=, #default_ignored_crawlers, #flush, #send_event

Methods inherited from Base

#flush, #send_event

Constructor Details

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

Returns a new instance of Users.



6
7
8
9
10
11
12
13
# File 'lib/rulesio/users.rb', line 6

def initialize(app, options={})
  @app, @options = app, RulesIO::Rack.config_options.merge(options)
  super(@app, @options)
  @options[:ignore_crawlers]      ||= default_ignored_crawlers
  @options[:ignore_if]            ||= Proc.new { |env| false }
  @options[:ignore_if_controller] ||= 'false'
  @options[:custom_data]          ||= Proc.new { |env| {} }
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rulesio/users.rb', line 15

def call(env)
  before = Time.now
  status, headers, response = @app.call(env)
  [status, headers, response]
rescue Exception => e
  status = 500
  raise e
ensure
  after = Time.now
  RulesIO.send_event event(env, status, after - before) unless should_be_ignored(env)
end