forked from rafl/moosex-declare
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make method keyword now only available by default in namespaces that …
…consumed MooseSetup. Also added tests for other inner keywords.
- Loading branch information
Showing
4 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package MooseX::Declare::Syntax::Keyword::Method; | ||
|
||
use Moose; | ||
|
||
use namespace::clean -except => 'meta'; | ||
|
||
with 'MooseX::Declare::Syntax::MethodDeclaration'; | ||
|
||
sub register_method_declaration { | ||
my ($self, $class, $method) = @_; | ||
return $class->meta->add_method($method->name, $method->body); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
use Test::More tests => 1; | ||
use Test::More tests => 6; | ||
|
||
use MooseX::Declare; | ||
|
||
TODO: { | ||
local $TODO = 'method is set up outside of classes and roles'; | ||
eval 'method foo ($bar) { }'; | ||
ok($@, 'method keyword not set up outside of classes'); | ||
for my $inner (qw( method around before after augment override )) { | ||
eval $inner . ' foo ($bar) { }'; | ||
ok($@, "$inner keyword not set up outside of classes"); | ||
} |