No such thing as a small change | |
PerlMonks |
Re^2: Question regarding proper handling of a Hash/HashRef structure in Moose-variantsby NERDVANA (Deacon) |
on Dec 22, 2021 at 20:46 UTC ( [id://11139844]=note: print w/replies, xml ) | Need Help?? |
I'll second this. The semantics expected by a random perl programmer are that
$object->noun($value) has an implied verb of "set" which replaces the conceptual value of that attribute. If you want to apply changes to an attribute, you should make a method with a different verb in it, like apply_limit. You can then decide whether the attribute should even be exposed or not. For some variations on the theme, consider HTTP::Headers header($name, $value). That one acts sort of like your code, setting one of multiple headers, but it is understood that there is not one single attribute named "header", there are many headers given by name of the first argument, and you are setting one of them to a new value. If you were implementing HTTP::Headers in Moose, you would not declare 'header' as an attribute.
In Section
Seekers of Perl Wisdom
|
|