fix property_list usage
This commit is contained in:
parent
ad0d81e4fe
commit
9178c4e274
1 changed files with 6 additions and 6 deletions
|
|
@ -35,7 +35,7 @@ sub import {
|
||||||
mro::set_mro($caller, 'c3');
|
mro::set_mro($caller, 'c3');
|
||||||
|
|
||||||
# construct an ordered list and hash of the properties
|
# construct an ordered list and hash of the properties
|
||||||
my @property_list;
|
my @propertyList;
|
||||||
my %properties;
|
my %properties;
|
||||||
if ( my $properties = delete $definition->{properties} ) {
|
if ( my $properties = delete $definition->{properties} ) {
|
||||||
# accept a hash and alphabetize it
|
# accept a hash and alphabetize it
|
||||||
|
|
@ -44,13 +44,13 @@ sub import {
|
||||||
}
|
}
|
||||||
for (my $i = 0; $i < @{ $properties }; $i += 2) {
|
for (my $i = 0; $i < @{ $properties }; $i += 2) {
|
||||||
my $property = $properties->[$i];
|
my $property = $properties->[$i];
|
||||||
push @property_list, $property;
|
push @propertyList, $property;
|
||||||
$properties{ $property } = $properties->[$i + 1];
|
$properties{ $property } = $properties->[$i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# accessors for properties
|
# accessors for properties
|
||||||
for my $property ( @property_list ) {
|
for my $property ( @propertyList ) {
|
||||||
no strict 'refs';
|
no strict 'refs';
|
||||||
$class->_install($caller, $property, sub {
|
$class->_install($caller, $property, sub {
|
||||||
if (@_ > 1) {
|
if (@_ > 1) {
|
||||||
|
|
@ -64,7 +64,7 @@ sub import {
|
||||||
else {
|
else {
|
||||||
# call _get_$property and use return
|
# call _get_$property and use return
|
||||||
if (my $get = $_[0]->can('_get_' . $property)) {
|
if (my $get = $_[0]->can('_get_' . $property)) {
|
||||||
return $_[0]->$get($value);
|
return $_[0]->$get($_[1]);
|
||||||
}
|
}
|
||||||
return $_[0]{properties}{$property};
|
return $_[0]{properties}{$property};
|
||||||
}
|
}
|
||||||
|
|
@ -91,10 +91,10 @@ sub import {
|
||||||
|
|
||||||
$class->_install($caller, 'getProperties', sub {
|
$class->_install($caller, 'getProperties', sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %props = map { $_ => 1 } @properties;
|
my %props = map { $_ => 1 } @propertyList;
|
||||||
# remove any properties from superclass list that exist in this class
|
# remove any properties from superclass list that exist in this class
|
||||||
my @allProperties = grep { ! $props{$_} } $self->maybe::next::method(@_);
|
my @allProperties = grep { ! $props{$_} } $self->maybe::next::method(@_);
|
||||||
push @allProperties, @properties;
|
push @allProperties, @propertyList;
|
||||||
return @allProperties;
|
return @allProperties;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue