Permalink
Browse files

Now a truly backward compatible version

  • Loading branch information...
1 parent bdf94cc commit bd71b4d6f31d2c79ea8941ee5366e26f58c9b46c @ruoso ruoso committed Jun 8, 2010
Showing with 27 additions and 5 deletions.
  1. +4 −0 Changes
  2. +1 −1 lib/MooseX/Method/Signatures.pm
  3. +5 −1 lib/MooseX/Method/Signatures/Meta/Method.pm
  4. +17 −3 t/meta.t
View
@@ -1,5 +1,9 @@
Version history for MooseX::Method::Signatures
+0.34 Tue, 08 Jun 2010 14:00:00 -0300
+ * Provides a version of reify that replaces the original version and
+ now finally CatalystX::Declare and MooseX::MultiMethods work.
+
0.33 Thu, 01 Jun 2010 13:47:34 -0300
* CatalystX::Declare seems to create a method object without a code
reference at all.
@@ -19,7 +19,7 @@ use aliased 'Devel::Declare::Context::Simple', 'ContextSimple';
use namespace::autoclean;
-our $VERSION = '0.33';
+our $VERSION = '0.34';
has package => (
is => 'ro',
@@ -176,12 +176,16 @@ around wrap => sub {
sub reify {
my $self = shift;
+ my %args = @_;
my %other_args = %{$self};
delete $other_args{body};
delete $other_args{actual_body};
- return $self->meta->name->wrap($self->body, %other_args, @_);
+ my $body = delete $args{body} || delete $args{actual_body} || $self->body;
+ my %final_args = (%other_args, %args);
+
+ return $self->meta->name->wrap($body, %final_args);
}
sub _build_parsed_signature {
View
@@ -62,20 +62,34 @@ dies_ok(sub {
# CatalystX::Declare seems to create a method without a code at all.
lives_and(sub {
- package Bar;
+ package Baz;
use metaclass;
my $method = MooseX::Method::Signatures::Meta::Method->wrap(
signature => '($class: Int :$foo, Str :$bar)',
package_name => __PACKAGE__,
- name => 'bar',
+ name => 'baz',
);
::isa_ok($method, 'Moose::Meta::Method');
# CatalystX::Declare uses reify directly. too bad.
my $other = $method->reify
- ( actual_body => sub { },
+ ( actual_body => sub {
+ my ($self, $foo, $bar) = @_;
+ return $bar x $foo;
+ },
);
::isa_ok($method, 'Moose::Meta::Method');
+
+ Baz->meta->add_method(baz => $other);
+});
+
+lives_and(sub {
+ is(Baz->baz(foo => 3, bar => 'baz'), 'bazbazbaz');
+});
+
+dies_ok(sub {
+ Baz->baz(foo => 'moo', bar => 'baz');
});
+

0 comments on commit bd71b4d

Please sign in to comment.