Implement keywords differently (successfully) in the Asset class. Extra tests to verify it in Asset.t

This commit is contained in:
Colin Kuskie 2010-06-04 11:33:06 -07:00
parent 4eca8bb993
commit 8c759ed7bc
5 changed files with 44 additions and 18 deletions

View file

@ -148,6 +148,21 @@ sub get_all_property_list {
return @names;
}
sub get_all_settable_list {
my $self = shift;
my @names = ();
my %seen = ();
foreach my $meta ($self->get_all_class_metas) {
push @names,
grep { !$seen{$_}++ }
map { $_->name }
sort { $a->insertion_order <=> $b->insertion_order }
grep { $_->does('WebGUI::Definition::Meta::Settable') }
$meta->get_attributes;
}
return @names;
}
#-------------------------------------------------------------------
=head2 get_attributes ( )

View file

@ -21,6 +21,8 @@ no warnings qw(uninitialized);
our $VERSION = '0.0.1';
with 'WebGUI::Definition::Meta::Settable';
=head1 NAME
Package WebGUI::Definition::Meta::Property

View file

@ -62,7 +62,7 @@ sub get {
my $self = shift;
if (@_) {
my $property = shift;
if ($self->meta->find_attribute_by_name($property)) {
if ($self->can($property)) {
return $self->$property;
}
return undef;
@ -88,7 +88,7 @@ is not an attribute of the object, then it is silently ignored.
sub set {
my $self = shift;
my $properties = @_ % 2 ? shift : { @_ };
my @orderedProperties = $self->getProperties;
my @orderedProperties = $self->meta->get_all_settable_list;
KEY: for my $property ( @orderedProperties ) {
next KEY unless exists $properties->{$property};
$self->$property($properties->{$property});