Class: Serega::SeregaPlugins::Preloads::PreloadPaths
- Inherits:
-
Object
- Object
- Serega::SeregaPlugins::Preloads::PreloadPaths
- Defined in:
- lib/serega/plugins/preloads/lib/preload_paths.rb
Overview
Utility that helps to transform preloads to array of paths
Example:
call({ a: { b: { c: {}, d: {} } }, e: {} })
=> [
[:a],
[:a, :b],
[:a, :b, :c],
[:a, :b, :d],
[:e]
]
Class Method Summary collapse
-
.call(preloads, path = [], result = []) ⇒ Hash
Transforms user provided preloads to array of paths.
Class Method Details
.call(preloads, path = [], result = []) ⇒ Hash
Transforms user provided preloads to array of paths
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/serega/plugins/preloads/lib/preload_paths.rb', line 29 def call(preloads, path = [], result = []) preloads = FormatUserPreloads.call(preloads) preloads.each do |key, nested_preloads| path << key result << path.dup call(nested_preloads, path, result) path.pop end result end |