Skip to content

Instantly share code, notes, and snippets.

@selmanj
Created October 4, 2016 22:04
Show Gist options
  • Select an option

  • Save selmanj/92cf83cd0d0c1df3cbf6700e7612d362 to your computer and use it in GitHub Desktop.

Select an option

Save selmanj/92cf83cd0d0c1df3cbf6700e7612d362 to your computer and use it in GitHub Desktop.
def process_collection(collection, key)
process_flatten_collection(collection, key) { |x| [yield(x)] }
end
def process_flatten_collection(collection, key)
@data[key] ||= []
@data_index[key] ||= {}
collection.each do |item|
yield(item).each do |uid, new_result|
next if uid.nil?
@data[key] << new_result
@data_index.store_path(key, uid, new_result)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment