Method: PDK::Config::Namespace#to_h

Defined in:
lib/pdk/config/namespace.rb

#to_hHash{String => Object}

Convert the namespace into a Hash of values, suitable for serialising and persisting to disk.

Child namespaces that are associated with their own files are excluded from the Hash (as their values will be persisted to their own files) and nil values are removed from the Hash.



135
136
137
138
139
140
141
142
143
144
# File 'lib/pdk/config/namespace.rb', line 135

def to_h
  data.inject({}) do |new_hash, (key, value)|
    new_hash[key] = if value.is_a?(PDK::Config::Namespace)
                      value.include_in_parent? ? value.to_h : nil
                    else
                      value
                    end
    new_hash.delete_if { |_, v| v.nil? }
  end
end