Commits

Toby Inkster committed 7ed0210 Draft

general tidy

Comments (0)

Files changed (2)

lib/MooseX/ABCD.pm

 package MooseX::ABCD;
 
+use 5.008;
+use strict;
+use warnings FATAL => qw[ all ];
+no warnings qw[ void once uninitialized numeric ];
+
 BEGIN {
 	$MooseX::ABCD::AUTHORITY = 'cpan:TOBYINK';
 	$MooseX::ABCD::VERSION   = '0.001';
 }
 
-use 5.008;
+use Carp;
 use Moose 2.00 ();
 use MooseX::ABC 0.06 ();
 use Moose::Exporter;
 
+# More imports
+BEGIN {
+	*class_of               = \&Class::MOP::class_of;
+	*apply_base_class_roles = \&Moose::Util::MetaRole::apply_base_class_roles;
+	*apply_metaroles        = \&Moose::Util::MetaRole::apply_metaroles;
+};
+
 sub requires
 {
-	shift->add_required_method(@_);
+	my $self = shift;
+	$self->add_required_method(@_);
 }
  
 Moose::Exporter->setup_import_methods(
 sub init_meta
 {
 	my ($package, %options) = @_;
-
-	Carp::confess("Can't make a role into an abstract base class")
-		if Class::MOP::class_of($options{for_class})->isa('Moose::Meta::Role');
-
-	Moose::Util::MetaRole::apply_metaroles(
-		for             => $options{for_class},
+	my $for = $options{for_class};
+	
+	confess("Can't make a role into an abstract base class")
+		if class_of($for)->isa('Moose::Meta::Role');
+	
+	apply_metaroles(
+		for             => $for,
 		class_metaroles => { class => ['MooseX::ABCD::Trait::Class'] },
 	);
-	Moose::Util::MetaRole::apply_base_class_roles(
-		for   => $options{for_class},
+	apply_base_class_roles(
+		for   => $for,
 		roles => ['MooseX::ABC::Role::Object'],
 	);
-
-	Class::MOP::class_of($options{for_class})->is_abstract(1);
-	return Class::MOP::class_of($options{for_class});
+	
+	class_of($for)->is_abstract(1);
+	return class_of($for);
 }
   
 1;
 
 =head1 SYNOPSIS
 
-	{
-		package Shape;
-		use Moose;
-		use MooseX::ABCD;
-		requires 'draw';
-		__PACKAGE__->meta->make_immutable;
-	}
-	
-	{
-		package Circle;
-		use Moose;
-		extends 'Shape';
-		sub draw {
-			...;
-		}
-		__PACKAGE__->meta->make_immutable;
-	}
-	
-	my $shape  = Shape->new;   # dies
-	my $circle = Circle->new;  # succeeds
-	
-	{
-		package Square;
-		use Moose;
-		extends 'Shape';
-		__PACKAGE__->meta->make_immutable;
-		# ^^^ dies, draw is unimplemented
-	}
+   {
+      package Shape;
+      use Moose;
+      use MooseX::ABCD;
+      requires 'draw';
+      __PACKAGE__->meta->make_immutable;
+   }
+   
+   {
+      package Circle;
+      use Moose;
+      extends 'Shape';
+      sub draw {
+         ...;
+      }
+      __PACKAGE__->meta->make_immutable;
+   }
+   
+   my $shape  = Shape->new;   # dies
+   my $circle = Circle->new;  # succeeds
+   
+   {
+      package Square;
+      use Moose;
+      extends 'Shape';
+      __PACKAGE__->meta->make_immutable;
+      # ^^^ dies, draw is unimplemented
+   }
 
 =head1 DESCRIPTION
 
 
 =head1 COPYRIGHT AND LICENCE
 
-This software is copyright (c) 2012 by Toby Inkster.
+This software is copyright (c) 2012-2013 by Toby Inkster.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.

lib/MooseX/ABCD/Trait/Class.pm

 package MooseX::ABCD::Trait::Class;
 
+use 5.008;
+use strict;
+use warnings FATAL => qw[ all ];
+no warnings qw[ void once uninitialized numeric ];
+
 BEGIN {
 	$MooseX::ABCD::Trait::Class::AUTHORITY = 'cpan:TOBYINK';
 	$MooseX::ABCD::Trait::Class::VERSION   = '0.001';
-}
+};
 
 use Moose::Role;
  
 	# we know that the base class has at least our base class role applied,
 	# so it's safe to replace it if there is only one wrapper.
 	elsif ($constructor->isa('Class::MOP::Method::Wrapped')
-	&& $constructor->get_original_method == Class::MOP::class_of('Moose::Object')->get_method('new'))
+	and $constructor->get_original_method == Class::MOP::class_of('Moose::Object')->get_method('new'))
 	{
 		push @options, replace_constructor => 1;
 	}
 };
  
 no Moose::Role ;;; "Yeah, baby, yeah!"
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.