Skip to content

Instantly share code, notes, and snippets.

@markiz
Last active July 15, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markiz/9b74bb26967cd5cfd8317cd784e50a90 to your computer and use it in GitHub Desktop.
Save markiz/9b74bb26967cd5cfd8317cd784e50a90 to your computer and use it in GitHub Desktop.
helper = lambda do |responses, ids, val|
if responses.empty?
ids.push(val)
elsif val.is_a?(Integer)
helper.call(responses, ids.push(val), boutique_curator.plan)
else
first, *rest = responses
helper.call(rest, ids, val[first])
end
end
collection_ids = helper.call(responses, [], boutique_curator.plan)
node = boutique_curator.plan
collection_ids = responses.each_with_object([]) do |response, collection_ids|
next_node = node[response]
if next_node.is_a?(Integer)
collection_ids << next_node
node = boutique_curator.plan
else
node = next_node
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment