Class: Jackpot::Cron

Inherits:
Object
  • Object
show all
Defined in:
lib/jackpot/cron.rb

Instance Method Summary collapse

Constructor Details

#initialize(customer_storage, logger) ⇒ Cron

Returns a new instance of Cron.



6
7
8
9
# File 'lib/jackpot/cron.rb', line 6

def initialize(customer_storage, logger)
  @customer_storage = customer_storage
  @logger           = logger
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/jackpot/cron.rb', line 11

def run
  overdue_customers = @customer_storage.overdue
  overdue_customers.each do |c|
    begin 
      c.pay_subscription
    rescue Jackpot::Error => e
      @logger.error "Something was wrong when trying to process #{c} payment. Exception was #{e}"
    end 
  end 
end