bump version to 1.09
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Code.pm
1 package Moose::Meta::Attribute::Native::Trait::Code;
2 use Moose::Role;
3 use Moose::Meta::Attribute::Native::MethodProvider::Code;
4
5 our $VERSION   = '1.09';
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
8
9 with 'Moose::Meta::Attribute::Native::Trait';
10
11 has method_provider => (
12     is        => 'ro',
13     isa       => 'ClassName',
14     predicate => 'has_method_provider',
15     default   => 'Moose::Meta::Attribute::Native::MethodProvider::Code',
16 );
17
18 sub _helper_type { 'CodeRef' }
19
20 no Moose::Role;
21
22 1;
23
24 =pod
25
26 =head1 NAME
27
28 Moose::Meta::Attribute::Native::Trait::Code - Helper trait for Code attributes
29
30 =head1 SYNOPSIS
31
32   package Foo;
33   use Moose;
34
35   has 'callback' => (
36       traits    => ['Code'],
37       is        => 'ro',
38       isa       => 'CodeRef',
39       default   => sub { sub { print "called" } },
40       handles   => {
41           call => 'execute',
42       },
43   );
44
45   my $foo = Foo->new;
46   $foo->call; # prints "called"
47
48
49 =head1 DESCRIPTION
50
51 This provides operations on coderef attributes.
52
53 =head1 PROVIDED METHODS
54
55 =over 4
56
57 =item B<execute(@args)>
58
59 Calls the coderef with the given args.
60
61 =item B<execute_method(@args)>
62
63 Calls the coderef with the the instance as invocant and given args.
64
65 =back
66
67 =head1 METHODS
68
69 =over 4
70
71 =item B<meta>
72
73 =item B<method_provider>
74
75 =item B<has_method_provider>
76
77 =back
78
79 =head1 BUGS
80
81 See L<Moose/BUGS> for details on reporting bugs.
82
83 =head1 AUTHOR
84
85   Florian Ragwitz <rafl@debian.org>
86
87 =head1 COPYRIGHT AND LICENSE
88
89 Copyright 2007-2009 by Infinity Interactive, Inc.
90
91 L<http://www.iinteractive.com>
92
93 This library is free software; you can redistribute it and/or modify
94 it under the same terms as Perl itself.
95
96 =cut