I think that I’m probably not writing lazily instantiated methods/attributes in the most ruby way. Take this method as an example:
def tax
@tax ||= Proc.new do
if flat_tax > commission_plan.tax_max
return commission_plan.tax_max
end if commission_plan.tax_max
if flat_tax < commission_plan.tax_min
return commission_plan.tax_min
end if commission_plan.tax_min
flat_tax
end.call
end
Is there a more ruby-like way to refactor this method?
1 Answer