Rename push to process on PushTarget for clearer semantics

"Push to target" reads naturally - we push the notification to the
target. "Target processes" also makes sense - the target receives
and handles the notification in its own way.

- Add class method PushTarget.process(notification) that instantiates
  and calls the instance method
- Rename instance method from push to process
- Add private push_to helper in Pushable for readable iteration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-01-22 18:02:25 +01:00
parent 3621df8f0f
commit 0948533da7
5 changed files with 27 additions and 23 deletions
+5 -1
View File
@@ -3,11 +3,15 @@ class Notification::PushTarget
delegate :card, to: :notification
def self.process(notification)
new(notification).process
end
def initialize(notification)
@notification = notification
end
def push
def process
return unless should_push?
perform_push
+8 -5
View File
@@ -16,9 +16,10 @@ module Notification::Pushable
private
def resolve_push_target(target)
if target.is_a?(Notification::PushTarget) then target
else
if target.is_a?(Symbol)
"Notification::PushTarget::#{target.to_s.classify}".constantize
else
target
end
end
end
@@ -28,9 +29,7 @@ module Notification::Pushable
end
def push
self.class.push_targets.each do |target|
target.new(self).push
end
self.class.push_targets.each { |target| push_to(target) }
end
def pushable?
@@ -42,6 +41,10 @@ module Notification::Pushable
end
private
def push_to(target)
target.process(self)
end
def payload_type
source_type.presence_in(%w[ Event Mention ]) || "Default"
end