Module: NameMagic::HashMethods

Defined in:
lib/y_support/name_magic/hash_methods.rb

Instance Method Summary collapse

Instance Method Details

#keys_to_namesObject

Maps the hash into one whose keys have been replaced with full names of the keys (using #full_name method).



7
8
9
10
# File 'lib/y_support/name_magic/hash_methods.rb', line 7

def keys_to_names # FIXME: Change to #keys_to_full_names
  with_keys do |key| key.name || key end
  # FIXME: Change #name to #full_name
end

#keys_to_names!Object

Modifies a hash in place so that the keys are replaced with key names (key objects are assumed to respond to #name method).



15
16
17
18
# File 'lib/y_support/name_magic/hash_methods.rb', line 15

def keys_to_names! # FIXME: Change to #keys_to_full_names!
  with_keys! do |key| key.name || key end
  # FIXME: Change #name to #full_name
end

#keys_to_ɴObject

Maps the hash into one whose keys have been replaced with names of the key objects (using #name method).



23
24
25
# File 'lib/y_support/name_magic/hash_methods.rb', line 23

def keys_to_ɴ
  with_keys do |key| key._name_ || key end
end

#keys_to_ɴ!Object

Modifies a hash in place so that the keys are replaced with key names (using #name method).



30
31
32
# File 'lib/y_support/name_magic/hash_methods.rb', line 30

def keys_to_ɴ!
  with_keys! do |key| key._name_ || key end
end