lib/mail_spy/manager.rb in mail_spy-0.0.3 vs lib/mail_spy/manager.rb in mail_spy-0.0.4
- old
+ new
@@ -3,11 +3,11 @@
# ------------------------------------------- ADD_TEMPLATE
# Programmatically add email templates with a schema of search and
# replaceable text
#
- def add_template(name, html_erb, text_erb, template_values_definition)
+ def create_template(name, html_erb, text_erb, template_values_definition)
MailSpy::EmailTemplate.create!(
{
:name => name,
:html_erb => html_erb,
:text_erb => text_erb,
@@ -16,28 +16,28 @@
end
# ------------------------------------------- ADD INSTANCE
# Adds a instance of a email template to the queue to send
#
- def add_instance(options)
+ def create_email(options)
options.to_options!
required_options = [
:template_name, :campaign, :stream, :component, :schedule_at, :subject,
:template_values, :from, :reply_to]
to_options = [:to, :cc, :bcc]
# Ensure that we have the required options
- required_options.each { |ro| raise "add_instance call missing #{ro}" unless options.include? ro }
+ required_options.each { |ro| raise "create_email call missing #{ro}" unless options.include? ro }
# Make sure we have someone to send to
has_sender = options.keys.select { |option| to_options.include? option.intern }.present?
raise "Email instance has no sender (to,cc,bcc were all blank)" unless has_sender
# Make sure we have a template
options[:template_name]
template = MailSpy::EmailTemplate.first(conditions: {name: options[:template_name]})
- raise "No template: #{options[:template_name]} found, try add_template first" unless template
+ raise "No template: #{options[:template_name]} found, try create_template first" unless template
# Make sure that
(required_options + to_options).each do |option|
unless MailSpy::Email.method_defined? "#{option}=".intern