Class: Hash
Overview
Extend Hash with some helper methods.
Instance Method Summary collapse
-
#all_present? ⇒ Boolean
Returns true if all values are present, otherwise false.
-
#each_present? ⇒ Boolean
Returns a hash with the values of the original hash replaced with true if the value is present and false if nil.
-
#mask_present ⇒ Object
Returns a hash with non-nil values of the original hash replaced with present.
Instance Method Details
#all_present? ⇒ Boolean
Returns true if all values are present, otherwise false
108 109 110 111 112 113 |
# 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? ⇒ Boolean
Returns a hash with the values of the original hash replaced with true if the value is present and false if nil.
117 118 119 120 121 122 123 |
# File 'lib/tektite_ruby_utils/present.rb', line 117 def each_present? result = {} each do |key, value| result[key] = value.present? end result end |