summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs/parallelizer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/chef_fs/parallelizer')
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb40
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 46a01cbb4c..7354bc5c82 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -112,31 +112,33 @@ class Chef
restricted_copy(@input_enumerable.take(n)).to_a
end
- class RestrictedLazy
- def initialize(parallel_enumerable, actual_lazy)
- @parallel_enumerable = parallel_enumerable
- @actual_lazy = actual_lazy
- end
+ if Enumerable.method_defined?(:lazy)
+ class RestrictedLazy
+ def initialize(parallel_enumerable, actual_lazy)
+ @parallel_enumerable = parallel_enumerable
+ @actual_lazy = actual_lazy
+ end
- def drop(*args, &block)
- input = @parallel_enumerable.input_enumerable.lazy.drop(*args, &block)
- @parallel_enumerable.restricted_copy(input)
- end
+ def drop(*args, &block)
+ input = @parallel_enumerable.input_enumerable.lazy.drop(*args, &block)
+ @parallel_enumerable.restricted_copy(input)
+ end
- def take(*args, &block)
- input = @parallel_enumerable.input_enumerable.lazy.take(*args, &block)
- @parallel_enumerable.restricted_copy(input)
- end
+ def take(*args, &block)
+ input = @parallel_enumerable.input_enumerable.lazy.take(*args, &block)
+ @parallel_enumerable.restricted_copy(input)
+ end
- def method_missing(method, *args, &block)
- @actual_lazy.send(:method, *args, &block)
+ def method_missing(method, *args, &block)
+ @actual_lazy.send(:method, *args, &block)
+ end
end
- end
- alias :original_lazy :lazy
+ alias :original_lazy :lazy
- def lazy
- RestrictedLazy.new(self, original_lazy)
+ def lazy
+ RestrictedLazy.new(self, original_lazy)
+ end
end
private