Method: BlueprinterActiveRecord::Helpers#count_preloads

Defined in:
lib/blueprinter-activerecord/helpers.rb

#count_preloads(preloads) ⇒ Integer

Count the number of preloads in a nested Hash.

Parameters:

  • preloads (Hash)

    Nested Hash of preloads

Returns:

  • (Integer)

    The number of associations in the Hash



23
24
25
26
27
# File 'lib/blueprinter-activerecord/helpers.rb', line 23

def count_preloads(preloads)
  preloads.reduce(0) { |acc, (_key, val)|
    acc + 1 + count_preloads(val)
  }
end