Skip to content

Instantly share code, notes, and snippets.

@akostadinov
Created August 19, 2021 11:18
Show Gist options
  • Save akostadinov/a220b718ffc6fb0851c7c4571b5249d5 to your computer and use it in GitHub Desktop.
Save akostadinov/a220b718ffc6fb0851c7c4571b5249d5 to your computer and use it in GitHub Desktop.
represent Rails configuration as YAML
def dump_config(object = Rails.application.config.class.class_variable_get(:@@options))
case object
when Array
object.map { |v| dump_config(v) }
when Hash
Hash[ object.map { |key, value| [key, dump_config(value)] } ]
when TrueClass, FalseClass, Numeric
object
else
object.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment