class Temescal::Configuration

Attributes

default_message[RW]

Public: Getter/Setter for default JSON message.

ignored_errors[R]

Public: Getter for ignored errors array.

meta_key[W]

Public: Setter for meta_key option.

monitors[R]

Public: Getter for monitors array.

raise_errors[W]

Public: Setter for raise_errors option.

Public Class Methods

new() click to toggle source

Public: Initializes configuration and monitors option.

Returns a new Configuration object.

# File lib/temescal/configuration.rb, line 22
def initialize
  @monitors = []
  @ignored_errors = []
end

Public Instance Methods

ignored_errors=(*errors) click to toggle source

Public: Setter for ignored_errors option.

errors - Zero or more Exception classes.

# File lib/temescal/configuration.rb, line 55
def ignored_errors=(*errors)
  @ignored_errors = errors.flatten
end
meta_key() click to toggle source

Public: Getter for meta_key option.

Returns the meta_key option or simply “meta” if null.

# File lib/temescal/configuration.rb, line 62
def meta_key
  @meta_key || "meta"
end
monitors=(*monitors) click to toggle source

Public: Setter for monitors option.

monitors - Zero or more Symbols representing monitoring services

supported by Temescal.

Raises NameError if a monitor Symbol is invalid.

# File lib/temescal/configuration.rb, line 33
def monitors=(*monitors)
  monitors.flatten.each do |monitor|
    monitor = camelize_symbol(monitor)
    @monitors << Temescal::Monitors.const_get(monitor)
  end

rescue NameError => exception
  strategy = exception.message.split(" ").last
  raise NameError.new("#{strategy} is not a valid monitoring strategy")
end
raise_errors?() click to toggle source

Public: Getter for raise_errors.

Returns true if raise_errors is configured to true or the application is running in a test environment, false otherwise.

# File lib/temescal/configuration.rb, line 48
def raise_errors?
  @raise_errors == true || ENV["RACK_ENV"] == "test"
end

Private Instance Methods

camelize_symbol(symbol) click to toggle source

Private: Converts a snake cased Symbol to a camel cased String.

Returns the converted String.

# File lib/temescal/configuration.rb, line 71
def camelize_symbol(symbol)
  symbol.to_s.split(/_/).map { |word| word.capitalize }.join
end