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