私はおそらく、遅延インスタンス化されたメソッド/属性を最もルビーな方法で書いているわけではないと思います。例として、次の方法を取り上げます。
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
このメソッドをリファクタリングするためのよりルビーのような方法はありますか?