From 15c5318a27ae919e8c2d784de3806a709809e0a6 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 7 Jan 2010 18:15:40 -0800 Subject: [PATCH] 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. --- lib/WebGUI/Definition/Meta/Class.pm | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Definition/Meta/Class.pm b/lib/WebGUI/Definition/Meta/Class.pm index f44616611..a01f5abf2 100644 --- a/lib/WebGUI/Definition/Meta/Class.pm +++ b/lib/WebGUI/Definition/Meta/Class.pm @@ -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