Skip to content

Instantly share code, notes, and snippets.

@johnfoconnor
Forked from bitwalker/.conf
Last active Aug 29, 2015
Embed
What would you like to do?
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