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