Class: Trackers::CommonService
- Inherits:
-
Object
- Object
- Trackers::CommonService
- Includes:
- ImageHelper
- Defined in:
- app/services/partner_service/trackers/common_service.rb
Instance Attribute Summary collapse
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#footer_text ⇒ Object
Returns the value of attribute footer_text.
-
#navigation ⇒ Object
Returns the value of attribute navigation.
Instance Method Summary collapse
-
#call ⇒ void
Tracks changes to the record, comparing the old and new values in the parameters.
-
#initialize(record:, params:, nav:) ⇒ CommonService
constructor
Initializes the service with the given record, parameters, and navigation context.
Methods included from ImageHelper
Constructor Details
#initialize(record:, params:, nav:) ⇒ CommonService
Initializes the service with the given record, parameters, and navigation context.
22 23 24 25 26 27 |
# File 'app/services/partner_service/trackers/common_service.rb', line 22 def initialize(record:, params:, nav:) @record = record @params = params @navigation = nav @changes = {} end |
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
15 16 17 |
# File 'app/services/partner_service/trackers/common_service.rb', line 15 def changes @changes end |
#footer_text ⇒ Object
Returns the value of attribute footer_text.
15 16 17 |
# File 'app/services/partner_service/trackers/common_service.rb', line 15 def @footer_text end |
#navigation ⇒ Object
Returns the value of attribute navigation.
15 16 17 |
# File 'app/services/partner_service/trackers/common_service.rb', line 15 def @navigation end |
Instance Method Details
#call ⇒ void
This method returns an undefined value.
Tracks changes to the record, comparing the old and new values in the parameters. Updates the `changes` hash with the differences for both text and image fields.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/partner_service/trackers/common_service.rb', line 33 def call record_type = @record.class.name.to_s old_data = @record.slice(*@params.keys.map(&:to_s)) new_data = @params new_data.each do |key, new_value| next if skiped_keys.include?(key.to_s) old_value = old_data[key.to_s] if key.to_s.include?('logo') || key.to_s.include?('item') key = :cover_image if key == :item handle_single_image_change(key, old_value, new_value, record_type) else key, old_value, new_value = transform_text_changes(key, old_value, new_value) format_text_change(key, old_value, new_value, record_type) end end end |