Class: CounterCacheUpdate::PolymorphicUpdatorService
- Inherits:
-
ServicePattern::Service
- Object
- ServicePattern::Service
- CounterCacheUpdate::PolymorphicUpdatorService
- Defined in:
- app/services/counter_cache_update/polymorphic_updator_service.rb
Instance Method Summary collapse
-
#initialize(reflection:) ⇒ PolymorphicUpdatorService
constructor
A new instance of PolymorphicUpdatorService.
- #perform ⇒ Object
Constructor Details
#initialize(reflection:) ⇒ PolymorphicUpdatorService
2 3 4 5 |
# File 'app/services/counter_cache_update/polymorphic_updator_service.rb', line 2 def initialize(reflection:) @class = reflection.active_record @reflection = reflection end |
Instance Method Details
#perform ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/services/counter_cache_update/polymorphic_updator_service.rb', line 7 def perform foreign_types.each do |foreign_type| CounterCacheUpdate::TableUpdatorService.execute!(reflection: @reflection, model_class: foreign_type.constantize) end succeed! end |