Module: LcpRuby::BulkUpdater
- Defined in:
- lib/lcp_ruby/bulk_updater.rb
Class Method Summary collapse
-
.tracked_update_all(scope, updates, action: :bulk_update, model_definition:) {|affected_ids, updates, action| ... } ⇒ Integer
Performs update_all on a scope and yields metadata for callers that need to react (e.g., auditing, event dispatch).
Class Method Details
.tracked_update_all(scope, updates, action: :bulk_update, model_definition:) {|affected_ids, updates, action| ... } ⇒ Integer
Performs update_all on a scope and yields metadata for callers that need to react (e.g., auditing, event dispatch).
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lcp_ruby/bulk_updater.rb', line 12 def self.tracked_update_all(scope, updates, action: :bulk_update, model_definition:) if block_given? affected_ids = scope.pluck(:id) return 0 if affected_ids.empty? result = scope.update_all(updates) yield(affected_ids, updates, action) result else scope.update_all(updates) end end |