Class: CounterCacheUpdate::TableUpdatorService
- Inherits:
-
ServicePattern::Service
- Object
- ServicePattern::Service
- CounterCacheUpdate::TableUpdatorService
- Defined in:
- app/services/counter_cache_update/table_updator_service.rb
Instance Attribute Summary collapse
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#reflection ⇒ Object
readonly
Returns the value of attribute reflection.
Instance Method Summary collapse
-
#initialize(reflection:, model_class: nil) ⇒ TableUpdatorService
constructor
A new instance of TableUpdatorService.
- #perform ⇒ Object
Constructor Details
#initialize(reflection:, model_class: nil) ⇒ TableUpdatorService
Returns a new instance of TableUpdatorService.
4 5 6 7 8 9 |
# File 'app/services/counter_cache_update/table_updator_service.rb', line 4 def initialize(reflection:, model_class: nil) @reflection = reflection @model_class = model_class @model_class ||= @reflection.class_name.constantize end |
Instance Attribute Details
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
2 3 4 |
# File 'app/services/counter_cache_update/table_updator_service.rb', line 2 def model_class @model_class end |
#reflection ⇒ Object (readonly)
Returns the value of attribute reflection.
2 3 4 |
# File 'app/services/counter_cache_update/table_updator_service.rb', line 2 def reflection @reflection end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 |
# File 'app/services/counter_cache_update/table_updator_service.rb', line 11 def perform model_class.connection.execute(sql) succeed! end |