Class: SendWithUsMailer::MailParams

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMailParams

:nodoc:



7
8
9
10
11
# File 'lib/send_with_us_mailer/mail_params.rb', line 7

def initialize #:nodoc:
  @email_data = {}
  @to = {}
  @from = {}
end

Instance Attribute Details

#email_dataObject (readonly)

Returns the value of attribute email_data.



5
6
7
# File 'lib/send_with_us_mailer/mail_params.rb', line 5

def email_data
  @email_data
end

#email_idObject (readonly)

Returns the value of attribute email_id.



5
6
7
# File 'lib/send_with_us_mailer/mail_params.rb', line 5

def email_id
  @email_id
end

#fromObject (readonly)

Returns the value of attribute from.



5
6
7
# File 'lib/send_with_us_mailer/mail_params.rb', line 5

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



5
6
7
# File 'lib/send_with_us_mailer/mail_params.rb', line 5

def to
  @to
end

Instance Method Details

#assign(key, value) ⇒ Object

:nodoc:



13
14
15
# File 'lib/send_with_us_mailer/mail_params.rb', line 13

def assign(key, value) #:nodoc:
  @email_data.merge!( key.to_sym => value )
end

#deliverObject

Invoke SendWithUs::Api to deliver the message. The SendWithUs module is implemented in the send_with_us gem.

IMPORTANT NOTE: SendWithUs must be configured prior to calling this method. In particular, the api_key must be set (following the guidelines in the send_with_us documentation).



38
39
40
# File 'lib/send_with_us_mailer/mail_params.rb', line 38

def deliver
  SendWithUs::Api.new.send_with(@email_id, @to, @email_data, @from)
end

#merge!(params = {}) ⇒ Object

:nodoc:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/send_with_us_mailer/mail_params.rb', line 17

def merge!(params={}) #:nodoc:
  params.each_pair do |key, value|
    case key
    when :email_id
      @email_id = value
    when :to
      @to.merge!(address: value)
    when :from
      @from.merge!(address: value)
    when :reply_to
      @from.merge!(reply_to: value)
    end
  end
end