1336 links
  • linx
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
  • ► Play Videos
Links per page: 20 50 100
page 1 / 1
2 results tagged attributes x
  • thumbnail
    How can I prevent Perl Moose Read-Only Attributes being set upon a call to new? - Stack Overflow

    Use the init_arg attribute configuration (see "Constructor parameters" in Moose::Manual::Attributes):

    package SOD::KuuAnalyze::ProdId;
    use Moose;
    
    has 'users' => (
        isa => 'ArrayRef[Str]', is => "ro",
        init_arg => undef,    # do not allow in constructor
    );
    1;
    February 3, 2022 at 9:58:55 AM UTC - permalink -
    QRCode
    - https://stackoverflow.com/questions/1814046/how-can-i-prevent-perl-moose-read-only-attributes-being-set-upon-a-call-to-new
    attributes moose new-operator perl privacy
  • Enumerating all attributes of a Moo object
    package Foo {
      use Moo;
      has a => (is => "ro");
      has b => (is => "ro");
    }
    
    my $bar = Foo->new(a => 42);
    
    # Print only 'a'
    say $_ for keys %{ $bar }
    
    # Print all attributes
    say $_ for keys( %{
       'Moo'->_constructor_maker_for('Foo')->all_attribute_specs
    });
    October 19, 2020 at 7:41:08 PM UTC - permalink -
    QRCode
    - https://www.perlmonks.org/?node_id=1043195
    attributes introspection meta moo oop perl
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation