Class: Trackers::GalleryService
- Inherits:
-
Object
- Object
- Trackers::GalleryService
- Defined in:
- app/services/partner_service/trackers/gallery_service.rb
Overview
The GalleryService class tracks changes to the restaurant's image gallery. It monitors additions and deletions of pictures, storing changes in a format suitable for notifying managers or logging actions.
Instance Attribute Summary collapse
-
#archived_images_ids ⇒ Object
Returns the value of attribute archived_images_ids.
-
#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
-
#initialize ⇒ GalleryService
constructor
A new instance of GalleryService.
-
#track_added_picture(picture) ⇒ void
Tracks the addition of a picture to the gallery.
-
#track_deleted_picture(pictures) ⇒ void
Tracks the deletion of pictures from the gallery.
Constructor Details
#initialize ⇒ GalleryService
Returns a new instance of GalleryService.
8 9 10 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 8 def initialize @archived_images_ids = [] end |
Instance Attribute Details
#archived_images_ids ⇒ Object
Returns the value of attribute archived_images_ids.
6 7 8 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 6 def archived_images_ids @archived_images_ids end |
#changes ⇒ Object
Returns the value of attribute changes.
6 7 8 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 6 def changes @changes end |
#footer_text ⇒ Object
Returns the value of attribute footer_text.
6 7 8 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 6 def @footer_text end |
#navigation ⇒ Object
Returns the value of attribute navigation.
6 7 8 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 6 def @navigation end |
Instance Method Details
#track_added_picture(picture) ⇒ void
This method returns an undefined value.
Tracks the addition of a picture to the gallery.
45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 45 def track_added_picture(picture) @changes = { gallery: { added: [MyImageHelper.new.fix_image_url(picture.item.url)], label: '1 Image has been added to the gallery', type: 'image', }, } @navigation = 'photo' end |
#track_deleted_picture(pictures) ⇒ void
This method returns an undefined value.
Tracks the deletion of pictures from the gallery.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/partner_service/trackers/gallery_service.rb', line 17 def track_deleted_picture(pictures) return if pictures.blank? if pictures.all?(&:valid?) archived_images(pictures, :item) removed = [] @archived_images_ids.each do |id| img_url = ArchivedImage.find(id).image.url removed << MyImageHelper.new.fix_image_url(img_url) end @changes = { gallery: { removed: removed, label: "#{pictures.count} Image has been deleted from the gallery", type: 'image', }, } end @navigation = 'photo' end |