moose based definition
This commit is contained in:
parent
59a562fb35
commit
88aba652c7
9 changed files with 420 additions and 0 deletions
55
lib/WebGUI/Definition/Role/Object.pm
Normal file
55
lib/WebGUI/Definition/Role/Object.pm
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
package WebGUI::Definition::Role::Object;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use 5.010;
|
||||
use Moose::Role;
|
||||
use namespace::autoclean;
|
||||
no warnings qw(uninitialized);
|
||||
|
||||
our $VERSION = '0.0.1';
|
||||
|
||||
sub get {
|
||||
my $self = shift;
|
||||
if (@_) {
|
||||
my $property = shift;
|
||||
if ($self->can($property)) {
|
||||
return $self->$property;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
my %properties = map { $_ => scalar $self->$_ } $self->meta->get_all_properties;
|
||||
return \%properties;
|
||||
}
|
||||
|
||||
sub set {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
for my $key ( keys %$properties ) {
|
||||
$self->$key($properties->{$key});
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub update {
|
||||
my $self;
|
||||
$self->set(@_);
|
||||
if ($self->can('write')) {
|
||||
$self->write;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue