Sha256: 346dff6df0ec46232b6973b5db650f562ca033357a8da4de8f6bf61df9ddb8e7

Contents?: true

Size: 920 Bytes

Versions: 2

Compression:

Stored size: 920 Bytes

Contents

module Afterparty
  class MailerJob
    attr_accessor :execute_at, :mail, :clazz, :method, :args
    def initialize clazz, method, *args
      # @mail = UserMailer.welcome_email(User.find(1))
      @clazz = UserMailer
      @method = method
      @args = args
    end
    
    def run
      @mail = @clazz.send @method, *@args
      @mail.deliver
    end

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

  class BasicJob
    attr_accessor :object, :method, :args
    def initialize object, method, *args
      @object = object
      @method = method
      @args = args
    end

    def run
      @object.send(:method, *@args)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
afterparty-0.1.1 lib/afterparty/jobs.rb
afterparty-0.1.0 lib/afterparty/jobs.rb