Class: Tocsin::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
8
9
10
11
# File 'lib/tocsin/config.rb', line 5

def initialize
  @exception_level  = StandardError
  @logger           = select_logger
  @mailer           = select_mailer
  @mailer_method    = select_mailer_method
  @queue            = :high
end

Instance Attribute Details

#exception_levelObject

Returns the value of attribute exception_level.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def exception_level
  @exception_level
end

#from_addressObject

Returns the value of attribute from_address.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def from_address
  @from_address
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def logger
  @logger
end

#mailerObject

Returns the value of attribute mailer.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def mailer
  @mailer
end

#mailer_methodObject

Returns the value of attribute mailer_method.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def mailer_method
  @mailer_method
end

#queueObject

Returns the value of attribute queue.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def queue
  @queue
end

#recipient_groupsObject

Returns the value of attribute recipient_groups.



3
4
5
# File 'lib/tocsin/config.rb', line 3

def recipient_groups
  @recipient_groups
end

Instance Method Details

#notify(recipients, parameters) ⇒ Object

notify [r1, r2], :of => filters, :by => notifier



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tocsin/config.rb', line 14

def notify(recipients, parameters)
  self.recipient_groups ||= []

  recipients = [recipients] unless recipients.is_a? Array
  filters   = parameters[:of] || {}
  notifier  = parameters[:by] || Tocsin::Notifiers.default_notifier

  group_config = { :recipients  => recipients,
                   :notifier    => notifier}.merge(filters)
  self.recipient_groups.push(group_config)
end