NAME
PNI::Item - is a base class
SYNOPSIS
package PNI::Point_2d;
use parent 'PNI::Item';
use strict;
sub new {
my $self = shift->SUPER::new;
$self->add('name');
$self->add( y => 0 );
$self->add( x => 0 );
return $self;
}
package PNI::Point_3d;
use parent 'PNI::Point_3d';
use strict;
sub new {
my $self = shift->SUPER::new;
$self->add( z => 0 );
return $self;
}
package main;
my $point = PNI::Point_3d->new;
DESCRIPTION
This is an inside out object, to provide encapsulation for PNI classes.
Every object has an id, for instance, the reference to the object itself is a blessed id.
Objects can be [un]decorated adding/removing attributes at runtime.
Every attribute value is a scalar or a reference.
METHODS
add
$self->add('x');
$self->add( y => 1 );
cleanup
del
get
my $x = $self->get('x');
has
$self->has('x'); # returns 1
$self->has('car'); # returns 0
Checks if exists attribute_name.
id
my $id = $self->id;
init
set
$self->set( x => 10 );
type
my $type = $self->type;
Returns the package name.