keyword method (ident?, proto?, block) {
$block->name($ident);
- $block->code("warn 'hello from Methods';");
+ $block->code($proto);
$block->terminate;
}
-sub action_ident {
- return @_;
-}
+sub action_ident { shift; } # return method name
sub action_proto {
- return @_;
+ my $proto = shift;
+ $proto =~ s/\s//g;
+ $proto = "\$self,$proto" if length($proto);
+ return " my ($proto) = \@_; ";
}
1;
use lib 'examples/';
use Methods;
-method something ($a, $b, $c) {
- return 1;
+method add ($a, $b, $c) {
+ return $a+$b+$c;
}
use Test::More qw/no_plan/;
use Data::Dumper;
-ok (Foobar->something);
+ok (Foobar->add(1,2,3)==6);
ok 1;