Encapsulate a method to return all the meta objects for classes used by an object.

Refactor the code out of get_all_properties into its own method.  This will be
used by the write method in Asset.pm, at least.
This commit is contained in:
Colin Kuskie 2010-01-07 18:15:40 -08:00
parent 72c114d031
commit 15c5318a27

View file

@ -46,6 +46,26 @@ These methods are available from this class:
#-------------------------------------------------------------------
=head2 get_all_class_metas ( )
Returns an array of all class meta objects for the classes in this class,
in the order they were created in the Definition.
=cut
sub get_all_class_metas {
my $self = shift;
my @metas = ();
CLASS: foreach my $class_name (reverse $self->linearized_isa()) {
my $meta = $self->initialize($class_name);
next CLASS unless $meta->isa('WebGUI::Definition::Meta::Class');
push @metas, $meta;
}
return @metas;
}
#-------------------------------------------------------------------
=head2 get_all_properties ( )
Returns an array of all Properties, in all classes, in the order they were
@ -56,9 +76,7 @@ created in the Definition.
sub get_all_properties {
my $self = shift;
my @properties = ();
CLASS: foreach my $className (reverse $self->linearized_isa()) {
my $meta = $self->initialize($className);
next CLASS unless $meta->isa('WebGUI::Definition::Meta::Class');
CLASS: foreach my $meta ($self->get_all_class_metas) {
push @properties,
sort { $a->insertion_order <=> $b->insertion_order } # In insertion order
grep { $_->isa('WebGUI::Definition::Meta::Property') } # that are Meta::Properties