Class: MerbExceptions::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-exceptions/notification.rb

Defined Under Namespace

Classes: Mailer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(details = nil) ⇒ Notification

Returns a new instance of Notification.



14
15
16
17
18
# File 'lib/merb-exceptions/notification.rb', line 14

def initialize(details = nil)
  @details = details || []
  Mailer.config = Merb::Plugins.config[:exceptions][:mailer_config]
  Mailer.delivery_method = Merb::Plugins.config[:exceptions][:mailer_delivery_method]
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



12
13
14
# File 'lib/merb-exceptions/notification.rb', line 12

def details
  @details
end

Instance Method Details

#deliver!Object



20
21
22
23
# File 'lib/merb-exceptions/notification.rb', line 20

def deliver!
  deliver_web_hooks!
  deliver_emails!
end

#deliver_emails!Object



32
33
34
35
36
37
# File 'lib/merb-exceptions/notification.rb', line 32

def deliver_emails!
  Merb.logger.info  "DELIVERING EXCEPTION EMAILS"
  email_addresses.each do |address|
    send_email(address)
  end
end

#deliver_web_hooks!Object



25
26
27
28
29
30
# File 'lib/merb-exceptions/notification.rb', line 25

def deliver_web_hooks!
  Merb.logger.info "DELIVERING EXCEPTION WEB HOOKS"
  web_hooks.each do |address|
    post_hook(address)
  end
end

#email_addressesObject



41
# File 'lib/merb-exceptions/notification.rb', line 41

def email_addresses; option_as_array(:email_addresses); end

#environmentsObject



43
# File 'lib/merb-exceptions/notification.rb', line 43

def environments; option_as_array(:environments); end

#paramsObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/merb-exceptions/notification.rb', line 45

def params
  @params ||=
  {
    'request_url'              => details['url'],
    'request_controller'       => details['params'][:controller],
    'request_action'           => details['params'][:action],
    'request_params'           => details['params'],
    'environment'              => details['environment'],
    'exceptions'               => details['exceptions'],
    'app_name'                 => Merb::Plugins.config[:exceptions][:app_name]
  }
end

#web_hooksObject



39
# File 'lib/merb-exceptions/notification.rb', line 39

def web_hooks; option_as_array(:web_hooks); end