Created
November 5, 2009 11:51
-
-
Save deppp/226997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Person; | |
use Class::MOP; | |
use Class::MOP::Class; | |
use Class::MOP::Attribute; | |
Class::MOP::Class->create( | |
'Person' => ( | |
version => '0.01', | |
attributes => [ | |
Class::MOP::Attribute->new( | |
firstname => ( | |
accessor => 'firstname', | |
predicate => 'has_firstname', | |
init_arg => 'firstname', | |
default => 'Luke' | |
) | |
), | |
Class::MOP::Attribute->new( | |
lastname => ( | |
accessor => 'lastname', | |
predicate => 'has_lastname', | |
init_arg => 'lastname', | |
default => 'Luke' | |
) | |
) | |
], | |
methods => { | |
fullname => sub { | |
my $self = shift; | |
return $self->firstname . " " . $self->lastname; | |
} | |
} | |
) | |
); | |
sub new { | |
my ($class, $args) = @_; | |
return bless $args, $class; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment