NAME

VSO - Very Simple Objects

SYNOPSIS

package Plane;

use VSO;

has 'width' => (
  is        => 'ro',
  isa       => 'Int',
);

has 'height' => (
  is        => 'ro',
  isa       => 'Int',
);

has 'points' => (
  is        => 'rw',
  isa       => 'ArrayRef[Point2d]',
  required  => 0,
);


package Point2d;

use VSO;

subtype 'ValidValue' =>
  as      'Int',
  where   { $_ >= 0 && $_ <= shift->plane->width },
  message { 'Value must be between zero and ' . shift->plane->width };

has 'plane' => (
  is        => 'ro',
  isa       => 'Plane',
  weak_ref  => 1,
);

has 'x' => (
  is        => 'rw',
  isa       => 'ValidValue'
);

has 'y' => (
  is        => 'rw',
  isa       => 'ValidValue'
);

after 'x' => sub {
  my ($s, $new_value, $old_value) = @_;
  warn "Moving $s from x$old_value to x$new_value";
};

after 'y' => sub {
  my ($s, $new_value, $old_value) = @_;
  warn "Moving $s from y$old_value to y$new_value";
};

package Point3d;

use VSO;

extends 'Point2d';

has 'z' => (
  is      => 'rw',
  isa     => 'Int',
);

sub greet { warn "Hello, World!" }

before 'greet' => sub {
  warn "About to greet you";
};

after 'greet' => sub {
  warn "I have greeted you";
};

DESCRIPTION

VSO aims to offer a declarative OO style for Perl with very little overhead, without being overly-minimalist.

MOOSE

This is not a drop-in replacement for Moose, Moo, Mo, Mouse or anything like that.

Those modules are very, very nice and there is a great ecosystem of things that work well with them. If that's what you want - use them instead.

VSO is just minding its own business over here, Keeping It Super, Simple.

TYPES

VSO offers the following type system, based on the Moose type system:

Any
Item
    Bool
    Undef
    Defined
        Value
            Str
                Num
                    Int
                ClassName
        Ref
            ScalarRef
            ArrayRef
            HashRef
            CodeRef
            RegexpRef
            GlobRef
                FileHandle
            Object

Missing from the Moose type system are:

Maybe[`a]

Rationale: If it's a 'Maybe[whatever]', just do required => 0

RoleName

Rationale: VSO does not currently support 'roles'. They aren't simple. Try explaining 'roles' to the new guy on your team.

...30 minutes later...

See? Not simple.

AUTHOR

John Drago <jdrago_999@yahoo.com>

LICENSE

This software is Free software and may be used and redistributed under the same terms as perl itself.