Module: Trackers::Helper
- Includes:
- ImageHelper
- Included in:
- PartnerService::ChangeTracker, TagService, ThumbnailService
- Defined in:
- app/services/partner_service/trackers/helper.rb
Overview
The Helper module provides utility methods for tracking changes in gallery or other models. It handles tracking of added, removed, or updated attributes, with specific handling for image attributes.
Instance Method Summary collapse
-
#track_changes(label:, nav:, type:, old_value:, new_value:) ⇒ void
Tracks changes to an attribute, storing details about the old and new values.
Methods included from ImageHelper
Instance Method Details
#track_changes(label:, nav:, type:, old_value:, new_value:) ⇒ void
This method returns an undefined value.
Tracks changes to an attribute, storing details about the old and new values. Special handling is provided for image attributes, including adding or removing URLs.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/partner_service/trackers/helper.rb', line 17 def track_changes(label:, nav:, type:, old_value:, new_value:) @navigation ||= nav field = rand(1000..9999) attr_changes = { type: type, label: label, model_type: 'single' } if type == 'image' added = new_value.present? && old_value.blank? removed = old_value.present? && new_value.blank? single_changed = old_value.present? && new_value.present? attr_changes[:added] = [fix_image_url(new_value)] if added attr_changes[:removed] = [fix_image_url(old_value)] if removed attr_changes[:old] = fix_image_url(old_value) if single_changed attr_changes[:new] = fix_image_url(new_value) if single_changed else attr_changes[:old] = old_value attr_changes[:new] = new_value end @changes[field] = attr_changes end |