Class: Mailer

Inherits:
Object show all
Defined in:
lib/tmis/engine/mailer/mailer.rb

Overview

~~~~~~~~~~~~~~~~~~~~~~~~~~

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


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