1
package Data::Perl::Role::Code;
2
$Data::Perl::Role::Code::VERSION = '0.002008';
3
# ABSTRACT: Wrapping class for Perl coderefs.
9
sub new { my $cl = shift; bless $_[0], $cl }
11
sub execute { $_[0]->(@_[1..$#_]) }
13
#sub execute_method { $_[0]->($_[0], @_[1..$#_]) }
14
sub execute_method { die 'This remains unimplemented for now.' }
24
Data::Perl::Role::Code - Wrapping class for Perl coderefs.
32
use Data::Perl qw/code/;
34
my $code = code(sub { 'Foo'} );
36
$code->execute(); # returns 'Foo';
40
This class provides a wrapper and methods for interacting with Perl coderefs.
42
=head1 PROVIDED METHODS
46
=item B<new($coderef)>
48
Constructs a new Data::Perl::Code object, initialized to $coderef as passed in,
51
=item * B<execute(@args)>
53
Calls the coderef with the given args.
55
=item * B<execute_method(@args)>
57
Calls the coderef with the the instance as invocant and given args. B<This is
58
currently disabled and triggers a die due to implementation details yet to be
69
=item * L<MooX::HandlesVia>
75
Matthew Phillips <mattp@cpan.org>
77
=head1 COPYRIGHT AND LICENSE
79
This software is copyright (c) 2014 by Matthew Phillips <mattp@cpan.org>.
81
This is free software; you can redistribute it and/or modify it under
82
the same terms as the Perl 5 programming language system itself.