NAME

TheForce - Midichlorian-free Perl5 OOP

DESCRIPTION

Moose and Mouse are great. But how do they work? Normally people don't really care - they just work. TheForce is an extremely limited version which only supports has and extends at the moment, but still makes OOP in Perl5 extremely easy. What's best is everything is containing in just 3 small modules so you can see what is happening in the background, if you're interested. What's best is you get to use TheForce in every package ;-)

SYNOPSIS

# Foo.pm
package Foo;

use TheForce;

has ( x => { is => 'rw', isa => 'Int', default => 5 } );
has ( greet => { is => 'ro', isa => 'Str', default => 'Hello, World!' } );    

sub sayHello {
    my $self = shift;
    say $self->greet;
}

1;

# Fooness.pm
package Fooness;

use TheForce;

extends 'Foo';

say Foo->x; # prints 5
Foo->x(7);
say Foo->x; # prints 7

my $foo = Foo->new;
$foo->sayHello(); # prints Hello, World!

METHODS

has

Creates an accessor for the particular package. Without arguments will return its value, or with arguments will set a new value. You can make the accessor read-only and set a specific type.

has (x => {
    is      => 'ro',   # read only
    isa     => 'Int',  # Integer only
    default => 7,      # default value
});

extends

Inherits the specified class.

package Foo;

extends 'MyPackage';

1;

AUTHOR

Brad Haywood <brad@geeksware.net>

LICENSE

You may distribute this code under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 195:

=cut found outside a pod block. Skipping to next block.