Class: GmailNotifier

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ GmailNotifier

Returns a new instance of GmailNotifier.



4
5
6
7
# File 'lib/gmail_notifier.rb', line 4

def initialize(options)
  @name, @password = options.delete(:name), options.delete(:password)
  @options = options
end

Instance Method Details

#notify(message, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/gmail_notifier.rb', line 9

def notify(message, options = {})
  options[:body] = message
  options[:subject] = message if !options.has_key? :subject
  @options.each {|k,v| options[k] = v if !options.has_key? k }
  
  GMailer.connect(@name, @password) do |g|
     g.send(options)
  end
end