More attribute => aspect changes. Add get_all_attributes_list, which returns a list of the names of all attributes.
This commit is contained in:
parent
d4f31870a3
commit
60375516ab
4 changed files with 26 additions and 9 deletions
|
|
@ -46,7 +46,7 @@ These methods are available from this class:
|
|||
|
||||
my ($import, $unimport, $init_meta) = Moose::Exporter->build_import_methods(
|
||||
install => [ 'unimport' ],
|
||||
with_meta => [ 'property', 'attribute' ],
|
||||
with_meta => [ 'property', 'aspect' ],
|
||||
also => 'Moose',
|
||||
);
|
||||
|
||||
|
|
@ -87,15 +87,15 @@ sub init_meta {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 attribute ( )
|
||||
=head2 aspect ( )
|
||||
|
||||
An attribute of the definition is typically static data which is never processed from a form
|
||||
or persisted to the database. In an Asset-style definition, an attribute would
|
||||
An aspect of the definition is typically static data which is never processed from a form
|
||||
or persisted to the database. In an Asset-style definition, an aspect would
|
||||
be the table name, the asset's name, or the path to the asset's icon.
|
||||
|
||||
=cut
|
||||
|
||||
sub attribute {
|
||||
sub aspect {
|
||||
my ($meta, $name, $value) = @_;
|
||||
if ($meta->can($name)) {
|
||||
$meta->$name($value);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ sub init_meta {
|
|||
|
||||
=head2 property ( $name, %options )
|
||||
|
||||
Extends WebGUI::Definition::property to copy the tableName attribute from the
|
||||
Extends WebGUI::Definition::property to copy the tableName aspect from the
|
||||
meta class into the options for each property.
|
||||
|
||||
=head3 $name
|
||||
|
|
|
|||
|
|
@ -46,9 +46,26 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get_all_attributes_list ( )
|
||||
|
||||
Returns an array of all attribute names across all meta classes.
|
||||
|
||||
=cut
|
||||
|
||||
sub get_all_attributes_list {
|
||||
my $self = shift;
|
||||
my @attributes = ();
|
||||
CLASS: foreach my $meta ($self->get_all_class_metas) {
|
||||
push @attributes, $meta->get_attribute_list;
|
||||
}
|
||||
return @attributes;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get_all_class_metas ( )
|
||||
|
||||
Returns an array of all class meta objects for the classes in this class,
|
||||
Returns an array of all WebGUI::Definition::Meta::Class objects for the classes in this class,
|
||||
in the order they were created in the Definition.
|
||||
|
||||
=cut
|
||||
|
|
@ -108,7 +125,7 @@ sub get_all_property_list {
|
|||
=head2 get_attributes ( )
|
||||
|
||||
Returns an array of all attributes, but only for this class. This is the
|
||||
API-safe way of doing $self->_attribute_map;
|
||||
API-safe way of doing values %{ $self->_attribute_map };
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ sub get {
|
|||
}
|
||||
return undef;
|
||||
}
|
||||
my %properties = map { $_ => scalar $self->$_ } $self->meta->get_property_list;
|
||||
my %properties = map { $_ => scalar $self->$_ } $self->meta->get_all_attributes_list;
|
||||
return \%properties;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue