6 use Test::More no_plan => 1;
13 ## meta-attribute example
16 package MyApp::Meta::Attribute::Labeled;
18 extends 'Moose::Meta::Attribute';
23 predicate => 'has_label',
26 package Moose::Meta::Attribute::Custom::Labeled;
27 sub register_implementation { 'MyApp::Meta::Attribute::Labeled' }
29 package MyApp::Website;
33 metaclass => 'Labeled',
36 label => "The site's URL",
49 # iterate over all the attributes in $self
50 my %attributes = %{ $self->meta->get_attribute_map };
51 while (my ($name, $attribute) = each %attributes) {
53 # print the label if available
54 if ($attribute->isa('MyApp::Meta::Attribute::Labeled')
55 && $attribute->has_label) {
56 $dump_value .= $attribute->label;
58 # otherwise print the name
63 # print the attribute's value
64 my $reader = $attribute->get_read_method;
65 $dump_value .= ": " . $self->$reader . "\n";
73 my $app = MyApp::Website->new(url => "http://google.com", name => "Google");
74 is($app->dump, q{The site's URL: http://google.com
76 }, '... got the expected dump value');