Class: Mailer
Overview
~~~~~~~~~~~~~~~~~~~~~~~~~~
Class Method Summary collapse
-
.email_valid?(email) ⇒ Boolean
Contract String => Bool.
Instance Method Summary collapse
-
#initialize(email, password, &block) ⇒ Mailer
constructor
Contract String, String, Proc => Any.
-
#send! ⇒ Object
Contract None => Any.
Constructor Details
#initialize(email, password, &block) ⇒ Mailer
Contract String, String, Proc => Any
10 11 12 13 14 15 16 |
# File 'lib/tmis/engine/mailer/mailer.rb', line 10 def initialize(email, password, &block) @email = Mailer.email_valid?(email) ? email : (raise ArgumentError, "Incorrect email: #{email}") @password = password set_defaults @mail = Mail.new(&block) @mail.charset = 'UTF-8' end |
Class Method Details
.email_valid?(email) ⇒ Boolean
Contract String => Bool
19 20 21 |
# File 'lib/tmis/engine/mailer/mailer.rb', line 19 def self.email_valid?(email) true & (/[\w\d\._\-]+@[\w\d\.\-]+[\.][\w\d\.\-]+/i =~ email) end |
Instance Method Details
#send! ⇒ Object
Contract None => Any
24 25 26 |
# File 'lib/tmis/engine/mailer/mailer.rb', line 24 def send! @mail.deliver! end |