Class: Cms::ErrorHandling::NotifierService

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNotifierService

Returns a new instance of NotifierService.



56
57
58
59
60
# File 'lib/cms/error_handling.rb', line 56

def initialize
  @notifiers = []

  autoload_notifiers
end

Instance Attribute Details

#notifiersObject (readonly)

Returns the value of attribute notifiers.



54
55
56
# File 'lib/cms/error_handling.rb', line 54

def notifiers
  @notifiers
end

Class Method Details

.serviceObject



50
51
52
# File 'lib/cms/error_handling.rb', line 50

def self.service
  @service ||= new
end

Instance Method Details

#notify(exception) ⇒ Object



62
63
64
# File 'lib/cms/error_handling.rb', line 62

def notify(exception)
  notifiers.each { |notifier| notifier.call exception }
end

#register_notifier_call(callable_object = nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


66
67
68
69
# File 'lib/cms/error_handling.rb', line 66

def register_notifier_call(callable_object = nil, &block)
  raise ArgumentError unless callable_object.respond_to?(:call) || block_given?
  @notifiers << (callable_object || block)
end