-
Notifications
You must be signed in to change notification settings - Fork 28
NotificationCenter should accept any Callable #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If given both a callback and a block, it would not be clear which would be invoked for the notification.
Not sure what's going on with Travis. The failure is occurring before the test step even begins. https://travis-ci.org/optimizely/ruby-sdk/jobs/602833534 |
@jasonkarns I apologize for the delay in getting back to you on this. Happy to approve once rebase/remerged. cc @mjc1283 |
I can, but I don't think that additional test is valuable. We're already asserting that Put another way, it's generally preferable to have only a single test fail for any given bug. Adding another test that fails for the same reason as an existing test doesn't provide value commensurate to its maintenance/carrying cost. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@jasonkarns can you please review this PR and merge it in this branch. It has lint fixes that should be resolved first. |
fix: lint errors
@jasonkarns Thanks. |
Summary
The NotificationCenter learns to accept any callable object as the
notification callback.
It is uncommon in Ruby to require
Method
instances when any Callablewill suffice. Indeed, the idiomatic object for callbacks is a block.
With this change, the notification center can accept any callable, not
only
Method
instances; that is, any object that responds tocall
(
Method
, lambdas, procs, or any object with a.call
method)If the callback parameter is omitted, a block may be provided instead.
Test plan
Issues
address item 3 of #213