4 use Test::More tests => 2;
8 package MouseX::AttributeHelpers::Number;
10 extends 'Mouse::Meta::Attribute';
13 my ($self, @args) = @_;
14 my $attr = $self->SUPER::create(@args);
15 my %provides = %{$attr->{provides}};
16 my $method_constructors = {
18 my ($attr, $name) = @_;
20 $_[0]->$name( $_[0]->$name() + $_[1])
24 while (my ($name, $aliased) = each %provides) {
25 $attr->associated_class->add_method(
26 $aliased => $method_constructors->{$name}->($attr, $attr->name)
32 package # hide me from search.cpan.org
33 Mouse::Meta::Attribute::Custom::Number;
34 sub register_implementation { 'MouseX::AttributeHelpers::Number' }
42 metaclass => 'Number',
51 can_ok 'Klass', 'add_number';
52 my $k = Klass->new(i=>3);