Sha256: 4be99bff387c7b73e799a3e837bc24c81c9848602230ee4b5aa57985c1c01500

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

if require 'google_hash'
  
  class ::GoogleHashSparseRubyToRuby
    
    alias each_pair each

    # This is mainly used in tests, which is
    # why we allow for a silly implementation.
    #
    def == hash
      return false unless hash.respond_to?(:to_h)
    
      self.each do |key, value|
        return false if hash[key] != value
      end
      hash.each do |key, value|
        return false if self[key] != value
      end
    
      true
    end
  
    # I am a hashy thing.
    #
    def to_hash
      true
    end
  
    # TODO
    #
    def inject init, &block
      result = init
      each do |key, value|
        result = block.call result, [key, value]
      end
      result
    end
  
    # TODO
    #
    def size
      result = 0
      # each only accepts a block
      each { result += 1 }
      result
    end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-4.27.1 lib/picky/backends/google_hash.rb