This is hands-down my favorite pattern in Ruby, and I use it all the time. I tend to take it further and do two things:
call
What this means is:
.()
What that means in practice is that when you want to kick off this class, you will end up saying something like
CalculatePayroll.(payroll)
instead of
PayrollCalculator.calculate(payroll)
This is hands-down my favorite pattern in Ruby, and I use it all the time. I tend to take it further and do two things:
call.What this means is:
.()syntax. That makes it look even more like you’re calling a function.What that means in practice is that when you want to kick off this class, you will end up saying something like
instead of