Skip to content

Instantly share code, notes, and snippets.

@johnfoconnor
Forked from bitwalker/.conf
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnfoconnor/51316bc82bd6e89a9b9f to your computer and use it in GitHub Desktop.
Save johnfoconnor/51316bc82bd6e89a9b9f to your computer and use it in GitHub Desktop.
my_app.complex_list.buzz.type = person
my_app.complex_list.buzz.age = 25
my_app.complex_list.fido.type = dog
my_app.complex_list.fido.opts.special_value = biz
[mappings: [
"my_app.complex_list.*": [
to: "my_app.complex_list",
datatype: [:complex],
default: []
]
"my_app.complex_list.*.opts.special_value": [
to: "my_app.complex_list",
datatype: :atom,
default: :bar
],
"my_app.complex_list.*.type" [
to: "my_app.complex_list",
datatype: :atom,
default: :undefined
],
"my_app.complex_list.*.age" [
to: "my_app.complex_list",
datatype: :integer,
default: 0
]]
translations: [
"my_app.complex_list.*": fn
_, {key, value_map}, acc ->
# example values
# {buzz, %{type: :person, age: 25, opts: %{special_value: :bar}}}
# {fido, %{type: :dog, age: 0, opts: %{special_value: :biz}}}
acc -> [[name: name,
type: value_map[:type],
age: value_map[:age],
opts: [special_value: value_map[:opts][:special_value]]
] | acc]
]]
[{my_app,
complex_list, [
[{name, buzz},
{type, person},
{age, 25},
{opts, [{special_value, bar}]},
],
[{name, fido},
{type, dog},
{age, 0},
{opts, [{special_value, biz}]}
]
]}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment