class Hash
Extend Hash
with some helper methods.
Public Instance Methods
all_present?()
click to toggle source
Returns true if all values are present, otherwise false
# File lib/tektite_ruby_utils/present.rb, line 108 def all_present? each do |_key, value| return false if value.nil? end true end
each_present?()
click to toggle source
Returns a hash with the values of the original hash replaced with true if the value is present and false if nil.
# File lib/tektite_ruby_utils/present.rb, line 117 def each_present? result = {} each do |key, value| result[key] = value.present? end result end
mask_present()
click to toggle source
Returns a hash with non-nil values of the original hash replaced with present.
# File lib/tektite_ruby_utils/present.rb, line 127 def mask_present result = {} each do |key, value| result[key] = value.present? ? present : nil end result end