Sha256: b3e5a0e0102da8209a64c17da90748531c15ddeb10fde70cbd2e4bdf9d5b331b

Contents?: true

Size: 469 Bytes

Versions: 51

Compression:

Stored size: 469 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

51 entries across 41 versions & 4 rubygems

Version Path
riak-client-2.6.0 lib/riak/core_ext/slice.rb
riak-client-2.5.0 lib/riak/core_ext/slice.rb
riak-client-2.3.0 lib/riak/core_ext/slice.rb
riak-client-2.2.2 lib/riak/core_ext/slice.rb
riak-client-2.2.1 lib/riak/core_ext/slice.rb
riak-client-noenc-1.0.0 lib/riak/core_ext/slice.rb
riak-client-2.2.0 lib/riak/core_ext/slice.rb
riak-client-2.2.0.pre1 lib/riak/core_ext/slice.rb
riak-client-2.1.0 lib/riak/core_ext/slice.rb
riak-client-1.4.5 lib/riak/core_ext/slice.rb
riak-client-2.0.0 lib/riak/core_ext/slice.rb
riak-client-2.0.0.rc2 lib/riak/core_ext/slice.rb
riak-client-2.0.0.rc1 lib/riak/core_ext/slice.rb
riak-client-1.4.4.1 lib/riak/core_ext/slice.rb
riak-client-1.4.4 lib/riak/core_ext/slice.rb
riak-client-1.4.3 lib/riak/core_ext/slice.rb
riak-client-1.4.2 lib/riak/core_ext/slice.rb
riak-client-1.4.1 lib/riak/core_ext/slice.rb
riak-client-1.4.0 lib/riak/core_ext/slice.rb
riak-client-1.2.0 lib/riak/core_ext/slice.rb