Class::Tangram 1.57 review

Download
by rbytes.net on

Class::Tangram is a Perl module for tangram-friendly classes, DWIM attributes. SYNOPSIS package MyObject; use base qw(Clas

License: Perl Artistic License
File size: 49K
Developer: Sam Vilain
0 stars award from rbytes.net

Class::Tangram is a Perl module for tangram-friendly classes, DWIM attributes.

SYNOPSIS

package MyObject;

use base qw(Class::Tangram);

our $fields = { int => [ qw(foo bar) ],
string => [ qw(baz quux) ] };

package main;

my $object = MyObject->new(foo => 2, baz => "hello");

print $object->baz(); # prints "hello"

$object->set_quux("Something");

$object->set_foo("Something"); # dies - not an integer

Class::Tangram is a tool for defining objects attributes. Simply define your object's fields/attributes using the same data structure introduced in _A Guided Tour of Tangram_ (see "SEE ALSO") and detailed in Tangram::Schema, and you get objects that work As You'd Expect(tm).

Class::Tangram has no dependancy upon Tangram, and vice versa. Neither requires anything special of your objects, nor do they insert any special fields into your objects. This is a very important feature with innumerable benefits, and few (if any) other object persistence tools have this feature.

So, fluff aside, let's run through how you use Class::Tangram to make objects.
First, you decide upon the attributes your object is going to have. You might do this using UML, or you might pick an existing database table and declare each column to be an attribute (you can leave out "id"; that one is implicit; also, leave out foreign keys until later).

Requirements:
Perl

Class::Tangram 1.57 search tags