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