summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-05-19 10:36:26 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-05-19 10:36:26 -0700
commit15d4ff065806478d1c20bf78ce7c2a4c2fb74022 (patch)
treecafcc3d38d2b68b10f4a52094d395373acf35c99 /lib/chef/chef_fs
parent9f0bb81b3c8f873456a8e18eff3bee24c573ac8c (diff)
downloadchef-15d4ff065806478d1c20bf78ce7c2a4c2fb74022.tar.gz
Do not provide "lazy" unless it is available (Ruby 2.0+)
Diffstat (limited to 'lib/chef/chef_fs')
-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