Sha256: d92b5b36fdf9eabbc081f1dbabded11a9eef81c15093b3b00364bac92b3802c3
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true class Serega module SeregaPlugins module Preloads # # 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 PreloadPaths class << self # # Transforms user provided preloads to array of paths # # @param value [Array,Hash,String,Symbol,nil,false] preloads # # @return [Hash] preloads transformed to hash # 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 end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems