1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
NAME
Class::Tiny::Chained - Minimalist class construction, with chained
attributes
SYNOPSIS
In Person.pm:
package Person;
use Class::Tiny::Chained qw( name );
1;
In Employee.pm:
package Employee;
use parent 'Person';
use Class::Tiny::Chained qw( ssn ), {
timestamp => sub { time } # attribute with default
};
1;
In example.pl:
use Employee;
my $obj = Employee->new( name => "Larry", ssn => "111-22-3333" );
# attribute setters are chainable
my $obj = Employee->new->name("Fred")->ssn("444-55-6666");
my $ts = $obj->name("Bob")->timestamp;
DESCRIPTION
Class::Tiny::Chained is a wrapper around Class::Tiny which makes the
generated attribute accessors chainable; that is, when setting an
attribute value, the object is returned so that further methods can be
called.
BUGS
Report any issues on the public bugtracker.
AUTHOR
Dan Book <dbook@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by Dan Book.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
SEE ALSO
Object::Tap, MooX::ChainedAttributes
|