package Employee; # <-- STEP 1 use Tangram; # <-- STEP 2 use strict; use vars qw(@ISA @EXPORT_OK $schema); use Exporter; # @ISA = qw(Exporter); # <-- STEP 3 @EXPORT_OK = qw($schema); # # The schema definition. <-- STEP 4 my $schema_def = { classes => { Employee => { fields => { string => [ "name", "title" ], int => [ "salary" ], } } } }; # Create the Tangram::Schema object. <-- STEP 5 $schema = Tangram::Schema->new($schema_def); # The implementation follows. <-- STEP 6 # The constructor. sub new { my $class = shift; my $the_name = shift; my $self = {}; bless ($self, $class); # Initialize instance variables. $self->{name} = $the_name; $self->{title} = undef; $self->{salary} = 0; return $self; } # Give this employee a raise. sub raise { my $self = shift; my $amount = shift; $self->{salary} += $amount; } # Set this employee's title. sub set_title { my $self = shift; my $the_title = shift; $self->{title} = $the_title; } 1;