Beginning of dzilization
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Code.pm
CommitLineData
952b939d 1package Moose::Meta::Attribute::Native::Trait::Code;
cdf3cae6 2use Moose::Role;
cdf3cae6 3
cdf3cae6 4our $AUTHORITY = 'cpan:STEVAN';
5
fc6ef638 6with 'Moose::Meta::Attribute::Native::Trait';
cdf3cae6 7
cdf3cae6 8sub _helper_type { 'CodeRef' }
9
10no Moose::Role;
11
121;
e8953f86 13
14=pod
15
e8953f86 16=head1 SYNOPSIS
17
18 package Foo;
19 use Moose;
20
21 has 'callback' => (
e132fd56 22 traits => ['Code'],
23 is => 'ro',
24 isa => 'CodeRef',
25 default => sub {
26 sub { print "called" }
27 },
28 handles => {
e8953f86 29 call => 'execute',
30 },
31 );
32
33 my $foo = Foo->new;
e132fd56 34 $foo->call; # prints "called"
e8953f86 35
36=head1 DESCRIPTION
37
7795e4de 38This trait provides native delegation methods for code references.
39
40=head1 DEFAULT TYPE
41
42If you don't provide an C<isa> value for your attribute, it will default to
43C<CodeRef>.
e8953f86 44
45=head1 PROVIDED METHODS
46
47=over 4
48
e132fd56 49=item * B<execute(@args)>
e8953f86 50
51Calls the coderef with the given args.
52
e132fd56 53=item * B<execute_method(@args)>
d9299060 54
55Calls the coderef with the the instance as invocant and given args.
56
e8953f86 57=back
58
59=head1 BUGS
60
d4048ef3 61See L<Moose/BUGS> for details on reporting bugs.
e8953f86 62
e8953f86 63=cut