Lots of doc improvements for native delegations.
[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
efa728b4 4our $VERSION = '1.15';
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
15no Moose::Role;
16
171;
e8953f86 18
19=pod
20
21=head1 NAME
22
8b09d5c3 23Moose::Meta::Attribute::Native::Trait::Code - Helper trait for Code attributes
e8953f86 24
25=head1 SYNOPSIS
26
27 package Foo;
28 use Moose;
29
30 has 'callback' => (
e132fd56 31 traits => ['Code'],
32 is => 'ro',
33 isa => 'CodeRef',
34 default => sub {
35 sub { print "called" }
36 },
37 handles => {
e8953f86 38 call => 'execute',
39 },
40 );
41
42 my $foo = Foo->new;
e132fd56 43 $foo->call; # prints "called"
e8953f86 44
45=head1 DESCRIPTION
46
47This provides operations on coderef attributes.
48
49=head1 PROVIDED METHODS
50
51=over 4
52
e132fd56 53=item * B<execute(@args)>
e8953f86 54
55Calls the coderef with the given args.
56
e132fd56 57=item * B<execute_method(@args)>
d9299060 58
59Calls the coderef with the the instance as invocant and given args.
60
e8953f86 61=back
62
63=head1 BUGS
64
d4048ef3 65See L<Moose/BUGS> for details on reporting bugs.
e8953f86 66
67=head1 AUTHOR
68
69 Florian Ragwitz <rafl@debian.org>
70
71=head1 COPYRIGHT AND LICENSE
72
73Copyright 2007-2009 by Infinity Interactive, Inc.
74
75L<http://www.iinteractive.com>
76
77This library is free software; you can redistribute it and/or modify
78it under the same terms as Perl itself.
79
80=cut