Permalink
Browse files

Tidy up the enumerator constructor

  • Loading branch information...
1 parent b66519e commit f8dc1c7b1545dc9c04d06330017810656287fea9 @ctfouts ctfouts committed Mar 20, 2012
Showing with 8 additions and 15 deletions.
  1. +8 −15 lib/Xape/Enumerator.pm
View
@@ -10,27 +10,20 @@ has 'charset' => (
required => 1,
);
-around BUILDARGS => sub {
- my $orig = shift;
- my $class = shift;
- return 1 unless $class;
-
- if (@_ == 1) {
- local $_[0] = $_[0];
- unless (ref $_[0]) {
- my $package_name = "Xape::Charset::$_[0]";
+around BUILDARGS => func($orig, $class, @args) {
+ if (@args == 1) {
+ unless (ref $args[0]) {
+ my $package_name = "Xape::Charset::$args[0]";
eval {
require $package_name;
import $package_name;
};
- $_[0] = $package_name->new;
+ $args[0] = $package_name->new;
}
- return $class->$orig(charset => $_[0]);
-
- }
- else {
- return $class->$orig(@_);
+ @args = (charset => $args[0]);
}
+
+ return $class->$orig(@args);
};
method sum(Str $input) {

0 comments on commit f8dc1c7

Please sign in to comment.