NAME¶
Catmandu::Fix::Bind::each - a binder that executes fixes for every (key, value)
pair in a hash
SYNOPSIS¶
# Create a hash:
# demo:
# nl: 'Tuin der lusten'
# en: 'The Garden of Earthly Delights'
# Create a list of all the titles, without the language tags.
do each(path: demo, var: t)
copy_field(t.value, titles.$append)
end
# This will result in:
# demo:
# nl: 'Tuin der lusten'
# en: 'The Garden of Earthly Delights'
# titles:
# - 'Tuin der lusten'
# - 'The Garden of Earthly Delights'
# Upcase every key in the root hash
# foo: bar
# test: 1234
do each(path:., var: t)
upcase(t.key)
end
# This will result in
# FOO: bar
# TEST: 1234
DESCRIPTION¶
The each binder will iterate over a hash and return a (key, value) pair (see the
Perl each <http://perldoc.perl.org/functions/each.html> function for the
inspiration for this bind) and execute all fixes for each pair.
The bind always returns a
"var.key" and
"var.value" pair which can be used in the
fixes.
CONFIGURATION¶
path¶
The path to a hash in the data.
var¶
The temporary field that will be created in the root of the record containing a
"key" and
"value" field containing the key and
value of the iterated data.
AUTHOR¶
Pieter De Praetere, "pieter.de.praetere at
helptux.be"
SEE ALSO¶
Catmandu::Fix::Bind::list Catmandu::Fix::Bind