Sha256: 8d38bf4cb30687582afc7189e7b7d7dc4af11b8d2c6e960bd2c0e2071c394800
Contents?: true
Size: 1.32 KB
Versions: 30
Compression:
Stored size: 1.32 KB
Contents
if Enumerable.instance_method(:any?).arity == 0 require 'backports/tools/alias_method_chain' require 'backports/tools/arguments' module Enumerable def any_with_pattern?(pattern = Backports::Undefined, &block) return any_without_pattern?(&block) if Backports::Undefined == pattern each_entry { |x| return true if pattern === x } false end Backports.alias_method_chain(self, :any?, :pattern) end end # MRI specializes `any?` for Array and Hash, so redefine those too if Array.instance_method(:any?).arity == 0 require 'backports/tools/alias_method_chain' require 'backports/tools/arguments' class Array def any_with_pattern?(pattern = Backports::Undefined, &block) return any_without_pattern?(&block) if Backports::Undefined == pattern each_entry { |x| return true if pattern === x } false end Backports.alias_method_chain(self, :any?, :pattern) end end if Hash.instance_method(:any?).arity == 0 require 'backports/tools/alias_method_chain' require 'backports/tools/arguments' class Hash def any_with_pattern?(pattern = Backports::Undefined, &block) return any_without_pattern?(&block) if Backports::Undefined == pattern each_entry { |x| return true if pattern === x } false end Backports.alias_method_chain(self, :any?, :pattern) end end
Version data entries
30 entries across 30 versions & 3 rubygems