Last active
November 14, 2015 11:22
-
-
Save tjormola/821460ee6393c4afc79c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
body common control | |
{ | |
bundlesequence => { "datatest" }; | |
} | |
body agent control | |
{ | |
ifelapsed => 0; | |
} | |
bundle agent datatest | |
{ | |
vars: | |
"data_with_list_of_strings" data => parsejson('{"key":["item1","item2"]}'); | |
"data_with_list_of_maps" data => parsejson('{"key":[{"name":"item1"},{"name":"item2"}]}'); | |
methods: | |
"handle_list_of_strings" usebundle => handle_list_of_strings(@(data_with_list_of_strings[key])); | |
"handle_list_of_maps" usebundle => handle_list_of_maps(@(data_with_list_of_maps[key])); | |
} | |
bundle agent handle_list_of_strings(list) | |
{ | |
vars: | |
"list_str" string => format("%S", list); | |
methods: | |
# Bundle is applied for each item in the list | |
"handle_list_items" usebundle => handle_string_item($(list)); | |
reports: | |
"$(this.bundle) called with list $(list_str)"; | |
} | |
bundle agent handle_list_of_maps(list) | |
{ | |
vars: | |
"list_str" string => format("%S", list); | |
methods: | |
# Bundle is not applied for each item in the list | |
"handle_list_items" usebundle => handle_map_item($(list)); | |
reports: | |
"$(this.bundle) called with list $(list_str)"; | |
} | |
bundle agent handle_string_item(item) | |
{ | |
reports: | |
"$(this.bundle) called with item $(item)"; | |
} | |
bundle agent handle_map_item(item) | |
{ | |
vars: | |
"item_str" string => format("%S", item); | |
methods: | |
"handle_string_item" usebundle => handle_string_item($(item[name])); | |
reports: | |
"$(this.bundle) called with item $(item_str)"; | |
} |
Author
tjormola
commented
Nov 14, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment