module CompactionHelpers
def compact_and_convert_array_to_hash(array)
- 
        (Hash)- A hash with keys from the array and compacted values.
Parameters:
- 
        array(Array) -- The array of key-value pairs to be converted.
def compact_and_convert_array_to_hash(array) array.transform_values do |value| compact_hash(value) end end
def compact_and_index_hash(hash)
- 
        (Hash)- A hash with indexed keys and the compacted original values.
Parameters:
- 
        hash(Hash) -- The hash to be converted and compacted.
def compact_and_index_hash(hash) compact_and_convert_array_to_hash(hash.map.with_index do |value, index| [index, value] end.to_h) end
def compact_hash(hash)
- 
        (Hash)- A compacted version of the input hash.
Parameters:
- 
        hash(Hash) -- The hash to be compacted.
def compact_hash(hash) hash.map do |key, value| next if value_ineligible?(value) || key == :random [key, value] end.compact.to_h end
def value_ineligible?(value)
- 
        (Boolean)- True if the value is ineligible, false otherwise.
Parameters:
- 
        value(Object) -- The value to be checked.
def value_ineligible?(value) [nil, [], {}, ''].include?(value) end