Sha256: 40272557694c588f4322435f768130b3c2b4ec7aef9aab80fdf9f64a2608c321

Contents?: true

Size: 727 Bytes

Versions: 6

Compression:

Stored size: 727 Bytes

Contents

# Must be defined outside of Kernel for jruby, see http://jira.codehaus.org/browse/JRUBY-3609
Enumerator = Enumerable::Enumerator unless Object.const_defined? :Enumerator # Standard in ruby 1.9

class Enumerator
  # new with block, standard in Ruby 1.9
  unless (self.new{} rescue false)
    def initialize_with_optional_block(*arg, &block)
      return initialize_without_optional_block(*arg, &nil) unless arg.empty?  # Ruby 1.9 apparently ignores the block if any argument is present
      initialize_without_optional_block(Backports::Yielder.new(&block))
    end
    Backports.alias_method_chain self, :initialize, :optional_block
  end

  alias_method :with_object, :each_with_object unless method_defined? :with_object
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
backports-1.13.1 lib/backports/1.8.8/enumerator.rb
backports-1.13.0 lib/backports/1.8.8/enumerator.rb
backports-1.12.3 lib/backports/1.8.8/enumerator.rb
backports-1.12.2 lib/backports/1.8.8/enumerator.rb
backports-1.12.1 lib/backports/1.8.8/enumerator.rb
backports-1.12.0 lib/backports/1.8.8/enumerator.rb