module HashCleaner

Constants

VERSION

Public Class Methods

clean(config) click to toggle source
# File lib/hashcleaner.rb, line 2
def self.clean(config)
  flat(config).reject do |key, element|
    is_redacted_credential(element) ||
    is_not_configurable(element) ||
    is_required_and_not_set(element)
  end
end

Private Class Methods

flat(c) click to toggle source
# File lib/hashcleaner.rb, line 23
def self.flat(c)
  c.each do |_, element|
    if element['type'] == 'collection' then
      element['value'].each do |v|
        v.keys.each do |key|
          v[key] = v[key]['value']
        end
      end
    end
  end
end
is_not_configurable(element) click to toggle source
# File lib/hashcleaner.rb, line 15
def self.is_not_configurable(element)
  !element['configurable']
end
is_redacted_credential(element) click to toggle source
# File lib/hashcleaner.rb, line 11
def self.is_redacted_credential(element)
  element['credential'] && element['value'].key('***')
end
is_required_and_not_set(element) click to toggle source
# File lib/hashcleaner.rb, line 19
def self.is_required_and_not_set(element)
  !element['optional'] && element['value'].nil?
end