7 our $VERSION = '1.000001'; # 1.0.1
9 our @EXPORT = qw($_tap);
11 our $_tap = sub { my ($obj, $call, @args) = @_; $obj->$call(@args); $obj };
17 Object::Tap - Tap into a series of method calls to alter an object
23 my $thing = My::Class->new(...);
27 you can instead write -
31 my $thing = My::Class->new(...)->$_tap(sub { $_[0]->set_foo(1) });
33 To realise why this might be useful, consider instead -
35 My::App->new(...)->$_tap(...)->run;
37 where a variable is thereby not required at all.
39 You can also pass extra args -
41 $obj->$_tap(sub { warn "Got arg: $_[1]" }, 'arg');
43 or use a method name instead of a sub name -
45 my $thing = My::Class->new(...)->$_tap(set_foo => 1);
49 mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
53 None yet. Well volunteered? :)
57 Copyright (c) 2014 the Object::Tap L</AUTHOR> and L</CONTRIBUTORS>
62 This library is free software and may be distributed under the same terms