Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Question regarding proper handling of a Hash/HashRef structure in Moose-variants

by NERDVANA (Deacon)
on Dec 22, 2021 at 20:46 UTC ( [id://11139844]=note: print w/replies, xml ) Need Help??


in reply to Re: Question regarding proper handling of a Hash/HashRef structure in Moose-variants
in thread Question regarding proper handling of a Hash/HashRef structure in Moose-variants

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.

  • Comment on Re^2: Question regarding proper handling of a Hash/HashRef structure in Moose-variants
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139844]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2024-04-18 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found