Sha256: 1e80e9124fc504892365ee94b8793c0cf7ee7f267974f54e51317c23aadce8f3

Contents?: true

Size: 514 Bytes

Versions: 4

Compression:

Stored size: 514 Bytes

Contents

# from Rails 6.0 activesupport.  Remove once defined by Opal activesupport
module Enumerable
  INDEX_WITH_DEFAULT = Object.new
  private_constant :INDEX_WITH_DEFAULT
  def index_with(default = INDEX_WITH_DEFAULT)
    if block_given?
      result = {}
      each { |elem| result[elem] = yield(elem) }
      result
    elsif default != INDEX_WITH_DEFAULT
      result = {}
      each { |elem| result[elem] = default }
      result
    else
      to_enum(:index_with) { size if respond_to?(:size) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hyper-component-1.0.alpha1.8 lib/hyperstack/ext/component/enumerable.rb
hyper-component-1.0.alpha1.7 lib/hyperstack/ext/component/enumerable.rb
hyper-component-1.0.alpha1.6 lib/hyperstack/ext/component/enumerable.rb
hyper-component-1.0.alpha1.5 lib/hyperstack/ext/component/enumerable.rb