docbrown/app/services/notifications/remove_all.rb
Anna Buianova 784afdf41e
Routine rubocop fixes (#19254)
* Rubocop fixes

* Rubocop fixes

* Fixed rubocop violation

* Fixed policies rubocop violations

* More rubocop fixes
2023-03-24 14:37:44 +03:00

25 lines
555 B
Ruby

module Notifications
class RemoveAll
def self.call(...)
new(...).call
end
def initialize(notifiable_ids, notifiable_type)
return unless %w[Article Comment Mention].include?(notifiable_type) && notifiable_ids.present?
@notifiable_type = notifiable_type
@notifiable_ids = notifiable_ids
end
def call
Notification.where(
notifiable_type: notifiable_type,
notifiable_id: notifiable_ids,
).delete_all
end
private
attr_reader :notifiable_type, :notifiable_ids
end
end