);
Class::MOP::Method->meta->add_method('wrap' => sub {
- my $class = shift;
- my $code = shift;
- my %options = @_;
+ my ( $class, @args ) = @_;
+
+ unshift @args, 'body' if @args % 2 == 1;
+
+ my %options = @args;
+ my $code = $options{body};
('CODE' eq ref($code))
|| confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
|| confess "You must supply the package_name and name parameters";
# return the new object
- $class->meta->new_object(body => $code, %options);
+ $class->meta->new_object(%options);
});
Class::MOP::Method->meta->add_method('clone' => sub {
# construction
sub wrap {
- my ( $class, $code, %params ) = @_;
+ my ( $class, @args ) = @_;
+
+ unshift @args, 'body' if @args % 2 == 1;
+
+ my %params = @args;
+ my $code = $params{body};
('CODE' eq ref($code))
|| confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
my $trace = '';
my $method = Class::MOP::Method->wrap(
- sub { $trace .= 'primary' },
+ body => sub { $trace .= 'primary' },
package_name => 'main',
name => '__ANON__',
);