Sha256: db78566878f654f191607e96eb02fdb3fcbe0ef00bc5826775990557c1d822ec

Contents?: true

Size: 487 Bytes

Versions: 5

Compression:

Stored size: 487 Bytes

Contents

unless {}.respond_to? :slice
  class Hash
    def slice(*keys)
      allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
      hash = {}
      allowed.each { |k| hash[k] = self[k] if has_key?(k) }
      hash
    end

    def slice!(*keys)
      keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
      omit = slice(*self.keys - keys)
      hash = slice(*keys)
      replace(hash)
      omit
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
riak-client-2.4.1 lib/riak/core_ext/slice.rb
riak-client-2.4.0 lib/riak/core_ext/slice.rb
riak-client-2.4.0.pre1 lib/riak/core_ext/slice.rb
riak-client-2.3.2 lib/riak/core_ext/slice.rb
riak-client-2.3.1 lib/riak/core_ext/slice.rb