logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Class::Tiny::Chained - Minimalist class construction, with chained attributes

Author

       Dan Book <dbook@cpan.org>

Bugs

       Report any issues on the public bugtracker.

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.

Name

       Class::Tiny::Chained - Minimalist class construction, with chained attributes

See Also

       Object::Tap, MooX::ChainedAttributes

perl v5.36.0                                       2022-12-09                          Class::Tiny::Chained(3pm)

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;

See Also