Module: JamfRubyExtensions::Hash::BackPorts

Included in:
Hash
Defined in:
lib/jamf/ruby_extensions/hash/backports.rb

Instance Method Summary collapse

Instance Method Details

#transform_keys(&block) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/jamf/ruby_extensions/hash/backports.rb', line 58

def transform_keys(&block)
  nh = {}
  each do |k, v|
    nk = yield k
    nh[nk] = v
  end
  nh
end

#transform_keys!(&block) ⇒ Object



67
68
69
# File 'lib/jamf/ruby_extensions/hash/backports.rb', line 67

def transform_keys!(&block)
  replace transform_keys(&block)
end

#transform_values(&block) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/jamf/ruby_extensions/hash/backports.rb', line 74

def transform_values(&block)
  nh = {}
  each do |k, v|
    nv = yield v
    nh[k] = nv
  end
  nh
end

#transform_values!(&block) ⇒ Object



83
84
85
# File 'lib/jamf/ruby_extensions/hash/backports.rb', line 83

def transform_values!(&block)
  replace transform_values(&block)
end