Class: Errbit::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
# File 'lib/errbit/configuration.rb', line 7

def initialize
  @host = nil
  @project_id = nil
  @api_key = nil
  @ignore = []
  @open_timeout = 2
  @read_timeout = 2
end

Instance Attribute Details

#api_key ⇒ Object

Returns the value of attribute api_key.



5
6
7
# File 'lib/errbit/configuration.rb', line 5

def api_key
  @api_key
end

#host ⇒ Object

Returns the value of attribute host.



5
6
7
# File 'lib/errbit/configuration.rb', line 5

def host
  @host
end

#ignore ⇒ Object

Returns the value of attribute ignore.



5
6
7
# File 'lib/errbit/configuration.rb', line 5

def ignore
  @ignore
end

#open_timeout ⇒ Object

Returns the value of attribute open_timeout.



5
6
7
# File 'lib/errbit/configuration.rb', line 5

def open_timeout
  @open_timeout
end

#project_id ⇒ Object

Returns the value of attribute project_id.



5
6
7
# File 'lib/errbit/configuration.rb', line 5

def project_id
  @project_id
end

#read_timeout ⇒ Object

Returns the value of attribute read_timeout.



5
6
7
# File 'lib/errbit/configuration.rb', line 5

def read_timeout
  @read_timeout
end

Instance Method Details

#ignored?(exception) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/errbit/configuration.rb', line 16

def ignored?(exception)
  ignore.any? do |pattern|
    case pattern
    when Module
      exception.is_a?(pattern)
    when Regexp
      pattern.match?(exception.message.to_s) || pattern.match?(exception.class.name.to_s)
    else
      pattern.to_s == exception.class.name
    end
  end
end

#validate! ⇒ Object

Raises:



29
30
31
32
33
34
# File 'lib/errbit/configuration.rb', line 29

def validate!
  missing = i[host project_id api_key].select { |attr| public_send(attr).nil? || public_send(attr).to_s.empty? }
  return if missing.empty?

  raise ConfigurationError, "Errbit is missing required configuration: #{missing.join(', ')}"
end