NAME
Soo - Simple object oriented system for Perl
VERSION
version 0.0.2
SYNOPSIS
In Person.pm:
package Person;
use Soo;
has 'name';
# has name => {}; is valid also
has age => { rw => 1, default => 0 }; # age can change
1;
In Employee.pm:
package Employee;
use Soo;
extends 'Person'; # or use parent 'Person';
has 'id';
has email => {
# set is used to change received values
# here we will make sure that email will be always lowercase
set => sub {
my $self = shift;
lc(shift);
}
};
1;
In example.pl:
use Employee;
my $obj = Employee->new( name => "Gabi", id => "123", email => "GABI@FOLLOW.ME" );
$obj->name; # Gabi
$obj->name('Gisele');
$obj->name; # Gabi - the name remains the same, because every method is by default readonly
$obj->id; # 123
$obj->age; # 0
$obj->age(19);
$obj->age; # 19 - age method was defined readwrite
$obj->email; # gabi@follow.me
# the email was specified in uppercase in the constructor
# but the set function changed it to lowercase
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at https://github.com/geovannyjs/soo/issues. You will be notified automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/geovannyjs/soo
git clone https://github.com/geovannyjs/soo.git
AUTHOR
Geovanny Junio <geovannyjs@gmail.com>