Sha256: b9718ca75f1f51af4b01b88bb399aedadef82271d8e33b993e55df5548c026de

Contents?: true

Size: 596 Bytes

Versions: 15

Compression:

Stored size: 596 Bytes

Contents

# frozen_string_literal: true

# Monkey patching the Ruby Core class Enumerator
class Enumerator
  def shy_peek
    begin
      ret = peek
    rescue StandardError
      ret = nil
    end
    ret
  end
end

# Recursively freeze self if it's Enumerable
# Supports all Ruby versions 1.8.* to 2.2.*+
module Kernel
  alias deep_freeze freeze
  alias deep_frozen? frozen?
end

# Adding deep_freeze and deep_frozen?
module Enumerable
  def deep_freeze
    unless @deep_frozen
      each(&:deep_freeze)
      @deep_frozen = true
    end
    freeze
  end

  def deep_frozen?
    !!@deep_frozen
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cotcube-helpers-0.2.4 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.2.3 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.2.2.5 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.2.2.4 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.2.2.3 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.2.1.1 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.2.0 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.10 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.9.2 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.9.1 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.9 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.8 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.7.4 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.7.3 lib/cotcube-helpers/enum_ext.rb
cotcube-helpers-0.1.7.2 lib/cotcube-helpers/enum_ext.rb