Method: Weak::Map::StrongSecondaryKeys#each_pair
- Defined in:
- lib/weak/map/strong_secondary_keys.rb
#each_pair {|key, value| ... } ⇒ self, Enumerator
Calls the given block once for each live key in self, passing the key
and value as parameters. Returns the weak map itself.
If no block is given, an Enumerator is returned instead.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/weak/map/strong_secondary_keys.rb', line 120 def each_pair return enum_for(__method__) { size } unless block_given? @keys.values.each do |raw_key| next if DeletedEntry === raw_key key = value!(raw_key) next unless (id = @key_map[key.__id__]) raw_value = @values[id] if missing?(raw_value) @keys[id] = DeletedEntry.new else yield [key, value!(raw_value)] end end self end |