Sha256: 5c5f135d578226c00b65cafbfe2e236bd9717f3b35d16a2107732c16bc35454a

Contents?: true

Size: 272 Bytes

Versions: 1

Compression:

Stored size: 272 Bytes

Contents

class FunctionalHash < Hash
  def [](*args)
    key = args.shift
    if fetch(key).is_a? Proc
      if fetch(key).arity == 0
        fetch(key).call
      else
        args.unshift(self)
        fetch(key).call(*args)
      end
    else
      super(key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
functional_hash-0.1.0 lib/functional_hash.rb