Permalink
Browse files

* methods.pm 0.03, now with "use methods-invoker" support.

  • Loading branch information...
1 parent c458028 commit 6f4390cda85c6a34457c8d4ba9711521db80c527 @audreyt committed Jul 4, 2011
Showing with 80 additions and 6 deletions.
  1. +4 −0 Changes
  2. +1 −0 Makefile.PL
  3. +16 −1 README
  4. +17 −1 README.mkdn
  5. +29 −4 lib/methods.pm
  6. +13 −0 t/methods-invoker.t
View
@@ -1,3 +1,7 @@
+[Changes for 0.03 - Tue Jul 5 06:49:16 CST 2011]
+
+* Add "use methods-invoker" optional flags to load invoker.pm as well.
+
[Changes for 0.02 - Sun Jun 19 18:00:41 CST 2011]
* Add auto-importing to true.pm as well.
View
@@ -4,4 +4,5 @@ requires $_ for qw(
true::VERSION
namespace::autoclean
Method::Signatures::Simple
+ invoker
);
View
17 README
@@ -17,6 +17,13 @@ SYNOPSIS
# "1;" no longer required here
+ With invoker support:
+
+ use methods-invoker;
+ method foo() {
+ $->bar(); # Write "$self->method" as "$->method"
+ }
+
DESCRIPTION
This module uses Method::Signatures::Simple to provide named and
anonymous methods with parameters, except with a shorter module name.
@@ -26,7 +33,15 @@ DESCRIPTION
importing module.
Finally, it also imports true so there's no need to put "1;" in the end
- of the importing module.
+ of the importing module anymore.
+
+OPTIONS
+ If the first argument on the "use" line is "-invoker", then it also
+ imports invoker automatically so one can write "$self->method" as
+ "$->method".
+
+ Other arguments are passed verbatim into Method::Signatures::Simple's
+ "import" function.
SEE ALSO
invoker, signatures
View
@@ -19,6 +19,13 @@ methods - Provide method syntax and autoclean namespaces
# "1;" no longer required here
+With [invoker](http://search.cpan.org/perldoc?invoker) support:
+
+ use methods-invoker;
+ method foo() {
+ $->bar(); # Write "$self->method" as "$->method"
+ }
+
# DESCRIPTION
This module uses [Method::Signatures::Simple](http://search.cpan.org/perldoc?Method::Signatures::Simple) to provide named and
@@ -29,7 +36,16 @@ It also imports [namespace::autoclean](http://search.cpan.org/perldoc?namespace:
importing module.
Finally, it also imports [true](http://search.cpan.org/perldoc?true) so there's no need to put `1;` in the
-end of the importing module.
+end of the importing module anymore.
+
+# OPTIONS
+
+If the first argument on the `use` line is `-invoker`, then it also
+imports [invoker](http://search.cpan.org/perldoc?invoker) automatically so one can write `$self->method`
+as `$->method`.
+
+Other arguments are passed verbatim into [Method::Signatures::Simple](http://search.cpan.org/perldoc?Method::Signatures::Simple)'s
+`import` function.
# SEE ALSO
View
@@ -1,18 +1,27 @@
package methods;
use 5.008;
-our $VERSION = '0.02';
+our $VERSION = '0.03';
use true;
use namespace::autoclean;
use Method::Signatures::Simple;
our @ISA = 'Method::Signatures::Simple';
method import {
+ my $want_invoker;
+ if (@_ and $_[0] eq '-invoker') {
+ $want_invoker = shift;
+ }
+
true->import;
namespace::autoclean->import( -cleanee => scalar(caller) );
+ Method::Signatures::Simple->import( @_, into => scalar(caller) );
- unshift @_, 'Method::Signatures::Simple';
- goto &Method::Signatures::Simple::import;
+ if ($want_invoker) {
+ require invoker;
+ unshift @_, 'invoker';
+ goto &invoker::import;
+ }
}
__END__
@@ -40,6 +49,13 @@ methods - Provide method syntax and autoclean namespaces
# "1;" no longer required here
+With L<invoker> support:
+
+ use methods-invoker;
+ method foo() {
+ $->bar(); # Write "$self->method" as "$->method"
+ }
+
=head1 DESCRIPTION
This module uses L<Method::Signatures::Simple> to provide named and
@@ -50,7 +66,16 @@ It also imports L<namespace::autoclean> so the C<method> helper function
importing module.
Finally, it also imports L<true> so there's no need to put C<1;> in the
-end of the importing module.
+end of the importing module anymore.
+
+=head1 OPTIONS
+
+If the first argument on the C<use> line is C<-invoker>, then it also
+imports L<invoker> automatically so one can write C<< $self->method >>
+as C<< $->method >>.
+
+Other arguments are passed verbatim into L<Method::Signatures::Simple>'s
+C<import> function.
=head1 SEE ALSO
View
@@ -0,0 +1,13 @@
+#!perl -T
+use Test::More tests => 1;
+use methods-invoker;
+method moose () {
+ $self->foo;
+}
+method foo () {
+ $->bar;
+}
+method bar () {
+ ok(1, '$->method and $self->method both works');
+}
+__PACKAGE__->moose;

0 comments on commit 6f4390c

Please sign in to comment.