Skip to content
Browse files

Alias is_class_loaded and load_class directly at compile time

    No reason to defer the Moose/Mouse decision until runtime
  • Loading branch information...
1 parent 4e9558a commit c193d86222275f871e190f85cb52e7f32d1055cc @sartak committed Apr 2, 2010
Showing with 7 additions and 10 deletions.
  1. +7 −10 lib/Any/Moose.pm
View
17 lib/Any/Moose.pm
@@ -167,16 +167,13 @@ sub any_moose {
return $fragment;
}
-sub load_class {
- my ($class_name) = @_;
- return Class::MOP::load_class($class_name) if moose_is_preferred();
- return Mouse::load_class($class_name);
-}
-
-sub is_class_loaded {
- my ($class_name) = @_;
- return Class::MOP::is_class_loaded($class_name) if moose_is_preferred();
- return Mouse::is_class_loaded($class_name);
+for (
+ [load_class => 'Class::MOP::load_class', 'Mouse::load_class'],
+ [is_class_loaded => 'Class::MOP::is_class_loaded', 'Mouse::is_class_loaded'],
+) {
+ my ($function_name, $moose_symbol, $mouse_symbol) = @$_;
+ no strict 'refs';
+ *{__PACKAGE__.'::'.$function_name} = moose_is_preferred() ? $moose_symbol : $mouse_symbol;
}
sub moose_is_preferred { $PREFERRED eq 'Moose' }

0 comments on commit c193d86

Please sign in to comment.
Something went wrong with that request. Please try again.