Module: SendableRails::ActionMailerWithSendable

Defined in:
lib/sendable_rails/action_mailer_ext.rb

Instance Method Summary collapse

Instance Method Details

#sendable_mail(params = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sendable_rails/action_mailer_ext.rb', line 5

def sendable_mail(params = {})
  template_id = params.delete(:template_id)

  assigns = {}
  instance_variables.each do |key|
    if match = key.to_s.match(/@([^\_]+)/)
      assigns[match[1]] = instance_variable_get(match[0])
    end
  end

  Sendable.client.email(template_id, params.merge(default_params).merge(assigns: assigns))
end