Created
August 19, 2021 11:18
-
-
Save akostadinov/a220b718ffc6fb0851c7c4571b5249d5 to your computer and use it in GitHub Desktop.
represent Rails configuration as YAML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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