table of contents
Sub::Accessor::Small(3pm) | User Contributed Perl Documentation | Sub::Accessor::Small(3pm) |
NAME¶
Sub::Accessor::Small - small toolkit for generating getter/setter methods
SYNOPSIS¶
package MyClass; use Sub::Accessor::Small; use Types::Standard qw( Int ); sub new { my $class = shift; my $self = bless \$class, $class; my %args = @_ == 1 ? %{ $_[0] } : @_; # Simple way to initialize each attribute for my $key ( sort keys %args ) { $self->$key( $args{$key} ); } return $self; } 'Sub::Accessor::Small'->new( package => __PACKAGE__, name => "foo", is => "rw", isa => Int, )->install_accessors(); package main; my $obj = MyClass->new( foo => 42 );
DESCRIPTION¶
This is a small toolkit for generating Moose-like attribute accessors. It does not generate a constructor.
It stores attribute values inside-out, but it is designed for Sub::Accessor::Small to be subclassed, making it easy to store attributes in other ways.
BUGS¶
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Lexical-Accessor>.
SEE ALSO¶
Lexical::Accessor.
AUTHOR¶
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE¶
This software is copyright (c) 2013-2014, 2017, 2020 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES¶
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2022-08-18 | perl v5.34.0 |