Class: Afterparty::MailerJob

Inherits:
Object
  • Object
show all
Defined in:
lib/afterparty/jobs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz, method, *args) ⇒ MailerJob

Returns a new instance of MailerJob.



4
5
6
7
8
9
# File 'lib/afterparty/jobs.rb', line 4

def initialize clazz, method, *args
  # @mail = UserMailer.welcome_email(User.find(1))
  @clazz = UserMailer
  @method = method
  @args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/afterparty/jobs.rb', line 3

def args
  @args
end

#clazzObject

Returns the value of attribute clazz.



3
4
5
# File 'lib/afterparty/jobs.rb', line 3

def clazz
  @clazz
end

#execute_atObject

Returns the value of attribute execute_at.



3
4
5
# File 'lib/afterparty/jobs.rb', line 3

def execute_at
  @execute_at
end

#mailObject

Returns the value of attribute mail.



3
4
5
# File 'lib/afterparty/jobs.rb', line 3

def mail
  @mail
end

#methodObject

Returns the value of attribute method.



3
4
5
# File 'lib/afterparty/jobs.rb', line 3

def method
  @method
end

Instance Method Details

#descriptionObject



16
17
18
19
20
# File 'lib/afterparty/jobs.rb', line 16

def description
  desc = "Mailer: #{(@clazz || "nil")}."
  desc << "Method: #{(@method || nil)}."
  desc << "Args: #{(@args || nil)}"
end

#runObject



11
12
13
14
# File 'lib/afterparty/jobs.rb', line 11

def run
  @mail = @clazz.send @method, *@args
  @mail.deliver
end