Skip to content
Boose is a lightweight Moose-like OO system for Perl5
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
t
MANIFEST.SKIP
Makefile.PL
README.pod

README.pod

Boose

Boose is a lightweight Moose-like OO system for Perl5.

Moose-like DSL (but not required)

    package Car;
    use Boose 'Vehicle';

    with 'BreakableRole';

    has 'number';

Constructor

    package Car;
    use Boose 'Vehicle';

    has 'number';

    ...

    Car->new(number => 12345);

Accessors

    package Car;
    use Boose;

    has number => {default => 12345};

    has size => {default => 'big'};

    ...

    my $car = Car->new;

    $car->number;

    # or

    $car->get_number;

Chained mutators

    package Car;
    use Boose;

    has number => {default => 12345};

    has size => {default => 'big'};

    ...

    my $car = Car->new;
    $car->set_number(54321)->set_size('small');

Static attributes

    package Car;
    use Boose;

    static 'counter';

    ...

    Car->set_counter(0);
    Car->counter; # 0

    my $car = Car->new;
    $cart->set_counter(1);
    $car->counter; # 1
    Car->counter;  # 1

Roles

    package BreakableRole;
    use Boose::Role;

    sub break {}

    package Car;
    use Boose;

    with 'BreakableRole';

Exception classes and try/catch/finally syntax (provided by Try::Tiny)

    package Car::Exception;
    use Boose '::Exception';

    has message => 'Car is broken';

    package Car;
    use Boose;

    sub break {
        try {
            die 42;
        }
        catch {
            throw 'Car::Exception';
        };
    }

Included implemented patterns

Iterator
Decorator

Forced requirement of Perl >= 5.10

Switches on strict and warnings
Provides 5.10 features

Moose-like syntax is not required

    package Car;

    use strict;
    use warnings;

    use base 'Boose::Base';

    __PACKAGE__->attr(number => {default => 12345});

    __PACKAGE__->add_role('Breakable');

    sub break {
        my $self = shift;

        $self->throw('Error!');
    }

Lightweight

Only really useful, tiny and one-thing-only modules are used.

Something went wrong with that request. Please try again.