Class: Errorkit::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/errorkit/config.rb', line 18

def initialize
  @errors_mailer = Errorkit::ErrorsMailer
  @errors_layout = false
  @ignore_exceptions = []
  @ignore_exceptions << ::ActiveRecord::RecordNotFound if defined? ::ActiveRecord::RecordNotFound
  @ignore_exceptions << ::AbstractController::ActionNotFound if defined? ::AbstractController::ActionNotFound
  @ignore_exceptions << ::ActionController::RoutingError if defined? ::ActionController::RoutingError
  @ignore_agents = %w{Googlebot MSNBot Baiduspider Bing Inktomi Yahoo AskJeeves FastCrawler InfoSeek Lycos YandexBot NewRelicPinger Pingdom}
  @max_notifications_per_minute = 5
  @max_notifications_per_quarter_hour = 10
  @format_errors = true
  @alert_threshold = 0.4
end

Instance Attribute Details

#alert_thresholdObject

Returns the value of attribute alert_threshold.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def alert_threshold
  @alert_threshold
end

#errors_classObject

Returns the value of attribute errors_class.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def errors_class
  @errors_class
end

#errors_controllerObject

Returns the value of attribute errors_controller.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def errors_controller
  @errors_controller
end

#errors_layoutObject

Returns the value of attribute errors_layout.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def errors_layout
  @errors_layout
end

#errors_mailerObject

Returns the value of attribute errors_mailer.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def errors_mailer
  @errors_mailer
end

#format_errorsObject

Returns the value of attribute format_errors.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def format_errors
  @format_errors
end

#ignore_agentsObject

Returns the value of attribute ignore_agents.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def ignore_agents
  @ignore_agents
end

#ignore_exceptionsObject

Returns the value of attribute ignore_exceptions.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def ignore_exceptions
  @ignore_exceptions
end

#mailer_recipientsObject

Returns the value of attribute mailer_recipients.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def mailer_recipients
  @mailer_recipients
end

#mailer_senderObject

Returns the value of attribute mailer_sender.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def mailer_sender
  @mailer_sender
end

#max_notifications_per_minuteObject

Returns the value of attribute max_notifications_per_minute.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def max_notifications_per_minute
  @max_notifications_per_minute
end

#max_notifications_per_quarter_hourObject

Returns the value of attribute max_notifications_per_quarter_hour.



3
4
5
# File 'lib/errorkit/config.rb', line 3

def max_notifications_per_quarter_hour
  @max_notifications_per_quarter_hour
end

Instance Method Details

#configObject



32
33
34
# File 'lib/errorkit/config.rb', line 32

def config
  self
end

#ignore_agent?(agent) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/errorkit/config.rb', line 41

def ignore_agent?(agent)
  return false if @ignore_agents.nil? || @ignore_agents.length == 0
  @ignore_agent_re ||= /(#{@ignore_agents.join('|')})/i
  !!(agent =~ @ignore_agents_re)
end

#ignore_exception?(exception) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/errorkit/config.rb', line 36

def ignore_exception?(exception)
  return false if @ignore_exceptions.nil? || @ignore_exceptions.length == 0
  @ignore_exceptions.include?(exception.class)
end