Last active
March 27, 2017 23:39
-
-
Save andrewvc/e84c477ce63a9a65ed4c79bab487aceb to your computer and use it in GitHub Desktop.
This file contains 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
define_filter :keymapper do | |
process do |event| | |
keys = event.get('[keys]') | |
vals = event.get('[vals]') | |
next unless keys && vals && !keys.empty? && !vals.empty? | |
keys.each.with_index do |key,i| | |
event.set(key, vals[i]) | |
end | |
event | |
end | |
test( | |
"keys map to vals", | |
:input => { "keys" => ["a", "b"], "vals" => [1,2] }, | |
:output => { "keys" => ["a", "b"], "vals" => 1,2, "a" => 1, "b" => 2 } | |
) | |
test( | |
"no keys, not problem", | |
:input => { "a" => "b" }, | |
:output => {} | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment