Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit a7f95d7

Browse files
committed
Services no longer must support all possible events
Prior to this change, a service had to define a receive method for every event, otherwise a NoMethodError would occur if that event is sent. This change allows services to define methods only for those events they care about, others will be ignored.
1 parent f4ce2aa commit a7f95d7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/cc/service.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ def initialize(config, payload)
7979
end
8080

8181
def receive
82-
if respond_to?(:receive_event)
83-
receive_event
84-
else
85-
public_send("receive_#{event}")
82+
methods = [:receive_event, :"receive_#{event}"]
83+
84+
methods.each do |method|
85+
if respond_to?(method)
86+
return public_send(method)
87+
end
8688
end
8789
end
8890

0 commit comments

Comments
 (0)