Sha256: e33a07817df9550bff0ac7833c4863a5621cfb99062f1aef042156d186469696
Contents?: true
Size: 535 Bytes
Versions: 9
Compression:
Stored size: 535 Bytes
Contents
# frozen_string_literal: true module ActiveRecordCustomPreloader class Preloader attr_reader :klass, :name, :args def initialize(klass, name, args) @klass = klass @name = name @args = args end # override this method in a subclass to provide customized preloading behavior def preload(records) values = args.fetch(:values).call(records) records.each do |record| value = values[record.id] record._set_custom_preloaded_value(name, value) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems