1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
use strict;
use warnings;
use Test::More skip_all => "Not implemented yet";
BEGIN {
package MyTrait::Label;
use MooseX::Role::Parameterized;
parameter default => (
is => 'rw',
isa => 'Str',
);
role {
my $p = shift;
has label => (
is => 'rw',
isa => 'Str',
default => $p->default,
);
};
};
BEGIN {
package MyApp::MooseX::LabeledAttributes;
use Moose::Exporter;
$INC{'MyApp/MooseX/LabeledAttributes.pm'} = 1;
# what is the secret sauce?
}
do {
package MyClass::LabeledURL;
use Moose;
use MyApp::MooseX::LabeledAttributes default => 'no label';
has name => (
is => 'ro',
);
has url => (
is => 'ro',
label => 'overridden',
);
no Moose;
no MyApp::MooseX::LabeledAttributes;
};
do {
package MyClass::LabeledPost;
use Moose;
use MyApp::MooseX::LabeledAttributes default => 'TODO!';
has name => (
is => 'ro',
);
has body => (
is => 'ro',
label => 'nevermind...',
);
no Moose;
no MyApp::MooseX::LabeledAttributes;
};
my $url_meta = MyClass::LabeledURL->meta;
is($meta->get_attribute('name')->label, 'no label');
is($meta->get_attribute('url')->label, 'overridden');
my $post_meta = MyClass::LabeledPost->meta;
is($meta->get_attribute('name')->label, 'TODO!');
is($meta->get_attribute('body')->label, 'nevermind...');
done_testing;
|