Sha256: 0dcad813a35faafdfce2ac3e7c160a90fdd42d28ac26f832fe227d4357b08051
Contents?: true
Size: 935 Bytes
Versions: 6
Compression:
Stored size: 935 Bytes
Contents
# frozen_string_literal: true class Serega module Plugins module Preloads class MainPreloadPath module ClassMethods # @param preloads [Hash] Formatted user provided preloads hash def call(preloads) return FROZEN_EMPTY_ARRAY if preloads.empty? main_path(preloads) end private # Generates path (Array) to the last included resource. # We need to know this path to include nested associations. # # main_path(a: { b: { c: {} }, d: {} }) # => [:a, :d] # def main_path(hash, path = []) current_level = path.size hash.each do |key, data| path.pop(path.size - current_level) path << key main_path(data, path) end path end end extend ClassMethods end end end end
Version data entries
6 entries across 6 versions & 1 rubygems