Skip to content

Instantly share code, notes, and snippets.

@andrewvc andrewvc/mini_filter.rb
Last active Mar 27, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.