Sha256: 95a20f1a7d60ad752852c6ebd38a38f560bc5e1087891ddbdfa6597e30bbdfe7

Contents?: true

Size: 587 Bytes

Versions: 30

Compression:

Stored size: 587 Bytes

Contents

require 'backports/1.8.7/enumerable/one'

if Enumerable.instance_method(:one?).arity == 0
  require 'backports/tools/alias_method_chain'
  require 'backports/tools/arguments'

  module Enumerable
    def one_with_pattern?(pattern = Backports::Undefined, &block)
      return one_without_pattern?(&block) if Backports::Undefined == pattern
      found_one = false
      each_entry do |o|
        if pattern === o
          return false if found_one
          found_one = true
        end
      end
      found_one
    end
    Backports.alias_method_chain(self, :one?, :pattern)
  end
end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
backports-3.25.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.24.1 lib/backports/2.5.0/enumerable/one.rb
backports-3.24.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.23.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.22.1 lib/backports/2.5.0/enumerable/one.rb
backports-3.22.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.21.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.20.2 lib/backports/2.5.0/enumerable/one.rb
backports-3.20.1 lib/backports/2.5.0/enumerable/one.rb
backports-3.20.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.19.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.18.2 lib/backports/2.5.0/enumerable/one.rb
backports-3.18.1 lib/backports/2.5.0/enumerable/one.rb
backports-3.18.0 lib/backports/2.5.0/enumerable/one.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/2.5.0/enumerable/one.rb
backports-3.17.2 lib/backports/2.5.0/enumerable/one.rb
backports-3.17.1 lib/backports/2.5.0/enumerable/one.rb
backports-3.17.0 lib/backports/2.5.0/enumerable/one.rb
backports-3.16.1 lib/backports/2.5.0/enumerable/one.rb
backports-3.16.0 lib/backports/2.5.0/enumerable/one.rb