Sha256: 661b51bf528574541969c794907d85f7662312c10e870a82fd606cb855ff2e58

Contents?: true

Size: 468 Bytes

Versions: 18

Compression:

Stored size: 468 Bytes

Contents

# -*- coding: utf-8 -*-

class Hash
  # Maps a hash into a hash, whose keys have been replaced with names of the
  # key objects (which are assumed to respond to +#name+ method).
  # 
  def keys_to_names
    with_keys do |key| key.name || key end
  end

  # Modifies a hash in place so that the keys are replaced with key names (key
  # objects are assumed to respond to +#name+ method).
  # 
  def keys_to_names!
    with_keys! do |key| key.name || key end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
y_support-2.0.43 lib/y_support/name_magic/hash.rb
y_support-2.0.42 lib/y_support/name_magic/hash.rb
y_support-2.0.41 lib/y_support/name_magic/hash.rb
y_support-2.0.39 lib/y_support/name_magic/hash.rb
y_support-2.0.38 lib/y_support/name_magic/hash.rb
y_support-2.0.37 lib/y_support/name_magic/hash.rb
y_support-2.0.36 lib/y_support/name_magic/hash.rb
y_support-2.0.35 lib/y_support/name_magic/hash.rb
y_support-2.0.34 lib/y_support/name_magic/hash.rb
y_support-2.0.33 lib/y_support/name_magic/hash.rb
y_support-2.0.31 lib/y_support/name_magic/hash.rb
y_support-2.0.30 lib/y_support/name_magic/hash.rb
y_support-2.0.29 lib/y_support/name_magic/hash.rb
y_support-2.0.28 lib/y_support/name_magic/hash.rb
y_support-2.0.26 lib/y_support/name_magic/hash.rb
y_support-2.0.25 lib/y_support/name_magic/hash.rb
y_support-2.0.24 lib/y_support/name_magic/hash.rb
y_support-2.0.23 lib/y_support/name_magic/hash.rb