Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rinaldifonseca/ecbd0bf9520f165db120cbbe9294ca56 to your computer and use it in GitHub Desktop.
Save rinaldifonseca/ecbd0bf9520f165db120cbbe9294ca56 to your computer and use it in GitHub Desktop.
PayRoll application, embedded in Rails, borrowing from Use Case Driven Architecture and DCI
module PayRoll
class PayDayService < Service
def initialize(date=Date.now, employees=datastore.find_all_employees)
@date = date
@employees = employees.each{|e| e.extend(Employee) }
end
def execute
@employees.each do |e|
if e.pay_date?(@date)
pc = PayCheck.new(e.calculate_pay(@date))
e.send_pay(pc)
end
end
end
end
module PayableEmployee
def pay_date?(date)
# ...
end
def send_pay(pay_check)
# ...
end
end
end
PayRoll::PayDayService.new(Employee.all).execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment