From: Shawn M Moore Date: Wed, 1 Apr 2009 03:07:35 +0000 (-0400) Subject: Remove third argument to trigger X-Git-Tag: 0.20~56 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=88b6c018ca804f12a431dacf12bb52d0df169e4c Remove third argument to trigger --- diff --git a/Changes b/Changes index fada970..4b0bf08 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Mouse 0.20 + * To improve Moose compat, the third argument to trigger + (the attribute metaobject) has been removed (Sartak) 0.19 Sun Mar 8 04:38:01 2009 * Parameterized type constraints for ArrayRef and HashRef (lestrrat) diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 20e8006..6c90b30 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -105,7 +105,7 @@ sub generate_accessor { } if ($trigger) { - $accessor .= '$trigger->('.$self.', '.$value.', $attribute);' . "\n"; + $accessor .= '$trigger->('.$self.', '.$value.');' . "\n"; } $accessor .= "}\n"; diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index a11479d..8b3f3a1 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -64,7 +64,7 @@ sub _generate_processattrs { } if ($attr->has_trigger) { - $code .= "\$attrs[$index]->{trigger}->( \$instance, \$value, \$attrs[$index] );\n"; + $code .= "\$attrs[$index]->{trigger}->( \$instance, \$value );\n"; } $code .= "\n} else {\n"; diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 079aa80..2a80b0e 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -27,7 +27,7 @@ sub new { if ref($instance->{$key}) && $attribute->is_weak_ref; if ($attribute->has_trigger) { - $attribute->trigger->($instance, $args->{$from}, $attribute); + $attribute->trigger->($instance, $args->{$from}); } } else { diff --git a/t/016-trigger.t b/t/016-trigger.t index 223e387..2f3a666 100644 --- a/t/016-trigger.t +++ b/t/016-trigger.t @@ -44,9 +44,9 @@ is(@trigger, 0, "trigger not called on read"); is($object->attr(50), 50, "setting the value"); is(@trigger, 1, "trigger was called on read"); -is_deeply([splice @trigger], [[$object, 50, $object->meta->get_attribute('attr')]], "correct arguments to trigger in the accessor"); +is_deeply([splice @trigger], [[$object, 50, undef]], "correct arguments to trigger in the accessor"); my $object2 = Class->new(attr => 100); is(@trigger, 1, "trigger was called on new with the attribute specified"); -is_deeply([splice @trigger], [[$object2, 100, $object2->meta->get_attribute('attr')]], "correct arguments to trigger in the constructor"); +is_deeply([splice @trigger], [[$object2, 100, undef]], "correct arguments to trigger in the constructor");