Class: ElasticNotifier::Notifier

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Notifier

Returns a new instance of Notifier.



15
16
17
18
19
20
21
22
# File 'lib/elastic_notifier.rb', line 15

def initialize(options)
  @repo ||= Elasticsearch::Persistence::Repository.new do
    client Elasticsearch::Client.new url: options[:url]
    index  options.fetch(:index, :elastic_notifier)
    type   options.fetch(:type, :signals)
  end
  @options = options
end

Instance Method Details

#notify_error(exception, params = {}) ⇒ Object Also known as: call



24
25
26
27
28
29
30
# File 'lib/elastic_notifier.rb', line 24

def notify_error(exception, params = {})
  overrides = {
    program_name: @options[:program_name]
  }.merge(params)
  error = Error.new(exception, overrides).to_hash
  @repo.save(error)
end