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-1.0.0.beta lib/riak/core_ext/slice.rb
riak-client-0.9.8 lib/riak/core_ext/slice.rb
riak-client-0.9.5 lib/riak/core_ext/slice.rb
riak-client-0.9.4 lib/riak/core_ext/slice.rb
riak-client-0.9.3 lib/riak/core_ext/slice.rb
riak-client-0.9.2 lib/riak/core_ext/slice.rb
riak-client-0.9.1 lib/riak/core_ext/slice.rb
riak-client-0.9.0 lib/riak/core_ext/slice.rb
riak-client-0.9.0.beta2 lib/riak/core_ext/slice.rb
riak-client-0.9.0.beta lib/riak/core_ext/slice.rb
riak-client-0.8.3 lib/riak/core_ext/slice.rb