A problem I see with this is there are two types of builder this could be used for:
to automatically create _build_gross_income and _build_taxes.sub _build_net_income { my $self = shift; return $self->gross_income - $self->taxes; }
to automatically create _build_gross_income and _build_children.sub _build_net_income { my $self = shift; my $gross = $self->gross_income; my $income_tax = do { if ($gross < 6_475) { 0 } elsif ($gross < 43_875) { (0.2 * ($gross - 6_475)) } elsif ($gross < 150_000) { (0.2 * (43_875 - 6_475)) + (0.4 * ($gross - 43_875)) } else { (0.2 * (43_875 - 6_475)) + (0.4 * (150_000 - 43_875)) + (0.5 * ($gross - 150_000)) } }; my $child_tax_credit = 545 * scalar @{$self->children}; my $taxes = $income_tax - $child_tax_credit; $taxes = 0 if $taxes < 0; return $gross - $taxes; }
In the case of complex builders, I don't think your module has much chance of success. In the case of simple ones, you're not saving me much work.
In reply to Re^3: Idea: Moose Mutal Coercion
by tobyink
in thread Idea: Moose Mutual Coercion
by k0st
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |