From: Dave Rolsky Date: Sat, 24 May 2008 19:23:57 +0000 (+0000) Subject: Sartak already renamed this more sensibly X-Git-Tag: 0_55~146 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70ea5ab3cfbf64927119b2abbb5ba4a720cd7ab7;p=gitmo%2FMoose.git Sartak already renamed this more sensibly --- diff --git a/t/000_recipes/021_recipe.t b/t/000_recipes/021_recipe.t deleted file mode 100644 index 7e5abcf..0000000 --- a/t/000_recipes/021_recipe.t +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 2; -use Test::Exception; - -BEGIN { - use_ok('Moose'); -} - -## meta-attribute example -{ - - package MyApp::Meta::Attribute::Labeled; - use Moose; - extends 'Moose::Meta::Attribute'; - - has label => ( - is => 'rw', - isa => 'Str', - predicate => 'has_label', - ); - - package Moose::Meta::Attribute::Custom::Labeled; - sub register_implementation { 'MyApp::Meta::Attribute::Labeled' } - - package MyApp::Website; - use Moose; - - has url => ( - metaclass => 'Labeled', - isa => 'Str', - is => 'rw', - label => "The site's URL", - ); - - has name => ( - is => 'rw', - isa => 'Str', - ); - - sub dump { - my $self = shift; - - my $dump_value = ''; - - # iterate over all the attributes in $self - my %attributes = %{ $self->meta->get_attribute_map }; - foreach my $name (sort keys %attributes) { - - my $attribute = $attributes{$name}; - - # print the label if available - if ($attribute->isa('MyApp::Meta::Attribute::Labeled') - && $attribute->has_label) { - $dump_value .= $attribute->label; - } - # otherwise print the name - else { - $dump_value .= $name; - } - - # print the attribute's value - my $reader = $attribute->get_read_method; - $dump_value .= ": " . $self->$reader . "\n"; - } - - return $dump_value; - } - -} - -my $app = MyApp::Website->new(url => "http://google.com", name => "Google"); -is($app->dump, q{name: Google -The site's URL: http://google.com -}, '... got the expected dump value'); - -