* Rubocop fixes * Rubocop fixes * Fixed rubocop violation * Fixed policies rubocop violations * More rubocop fixes
28 lines
587 B
Ruby
28 lines
587 B
Ruby
module NotificationSubscriptions
|
|
class Update
|
|
def self.call(...)
|
|
new(...).call
|
|
end
|
|
|
|
def initialize(notifiable)
|
|
@notifiable = notifiable
|
|
end
|
|
|
|
def call
|
|
return unless [Article].include?(notifiable.class)
|
|
|
|
notification_subscriptions = NotificationSubscription.where(
|
|
notifiable_id: notifiable.id,
|
|
notifiable_type: notifiable.class.name,
|
|
)
|
|
|
|
return if notification_subscriptions.none?
|
|
|
|
notification_subscriptions.update_all(user_id: notifiable.user_id)
|
|
end
|
|
|
|
private
|
|
|
|
attr_reader :notifiable
|
|
end
|
|
end
|