Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed fd892bb

Class::XSAccessor'ised maxdepth and mindepth.

  • Participants
  • Parent commits 8f591be

Comments (0)

Files changed (1)

File File-Find-Object-Rule/lib/File/Find/Object/Rule.pm

         "rules" => "rules",
         "_relative" => "_relative",
         "_subs" => "_subs",
+        "_maxdepth" => "_maxdepth",
+        "_mindepth" => "_mindepth",
     }
     ;
 
         _subs     => [],  # [1]
         iterator => [],
         extras   => {},
-        maxdepth => undef,
-        mindepth => undef,
+        _maxdepth => undef,
+        _mindepth => undef,
         _relative => 0,
     }, $class;
 }
 
 =cut
 
-for my $setter (qw( maxdepth mindepth )) {
-    my $sub = sub {
-        my $self = _force_object shift;
-        $self->{$setter} = shift;
-        $self;
-    };
-    no strict 'refs';
-    *$setter = $sub;
+sub maxdepth {
+    my $self = _force_object shift;
+    $self->_maxdepth(shift);
+    return $self;
 }
 
+sub mindepth {
+    my $self = _force_object shift;
+    $self->_mindepth(shift);
+    return $self;
+}
 
 =item C<relative>
 
         my $path_base = fileparse($path);
         my @args = ($path_base, $path_dir, $path);
         local $_ = $path_base;
-        my $maxdepth = $self->{maxdepth};
-        my $mindepth = $self->{mindepth};
+        my $maxdepth = $self->_maxdepth;
+        my $mindepth = $self->_mindepth;
 
         my $comps = $path_obj->full_components();