Navigation Menu

Skip to content

Commit

Permalink
Make method keyword now only available by default in namespaces that …
Browse files Browse the repository at this point in the history
…consumed MooseSetup.

Also added tests for other inner keywords.
  • Loading branch information
phaylon authored and rafl committed May 3, 2009
1 parent d56dc28 commit 959ac70
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 0 additions & 3 deletions lib/MooseX/Declare.pm
Expand Up @@ -3,7 +3,6 @@ use warnings;

package MooseX::Declare;

use MooseX::Method::Signatures;
use aliased 'MooseX::Declare::Syntax::Keyword::Class', 'ClassKeyword';
use aliased 'MooseX::Declare::Syntax::Keyword::Role', 'RoleKeyword';

Expand All @@ -22,8 +21,6 @@ sub import {
for my $keyword ($class->keywords) {
$keyword->setup_for($caller, %args);
}

MooseX::Method::Signatures->setup_for($caller)
}

sub keywords {
Expand Down
14 changes: 14 additions & 0 deletions lib/MooseX/Declare/Syntax/Keyword/Method.pm
@@ -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;
4 changes: 4 additions & 0 deletions lib/MooseX/Declare/Syntax/MooseSetup.pm
Expand Up @@ -6,6 +6,7 @@ use Moose::Util qw( find_meta );
use Sub::Install qw( install_sub );

use aliased 'MooseX::Declare::Syntax::Keyword::MethodModifier';
use aliased 'MooseX::Declare::Syntax::Keyword::Method';
use aliased 'MooseX::Declare::Syntax::Keyword::Clean', 'CleanKeyword';

use namespace::clean -except => 'meta';
Expand All @@ -25,6 +26,9 @@ sub import_symbols_from { 'Moose' }

around default_inner => sub {
return [
Method->new(
identifier => 'method',
),
MethodModifier->new(
identifier => 'around',
modifier_type => 'around',
Expand Down
9 changes: 4 additions & 5 deletions t/inner_keywords.t
@@ -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");
}

0 comments on commit 959ac70

Please sign in to comment.