Conversation
oakbani
left a comment
There was a problem hiding this comment.
Please see if we can accomodate block of code as param to add_notification such as
http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks/
|
@oakbani Implemented block and related unit tests. Please review. |
|
@msohailhussain It's ready. Should we create PR to Optimizely? |
| end | ||
|
|
||
| def add_notification_listener(notification_type, notification_callback) | ||
| def add_notification_listener(notification_type, callback = nil, &block) |
There was a problem hiding this comment.
this is wrong approach.
either you should add two listeners method, not default argument.
There was a problem hiding this comment.
Ruby does not support method overloading.
We could only send in default arguments and the other way is like 'method_name(*args)'.
https://www.ruby-forum.com/topic/890619
Proc and lambda are used as closures to send a block in arguments, which is already being used.
|
|
||
| return nil unless notification_type_valid?(notification_type) | ||
|
|
||
| notification_callback = callback.present? ? callback : block |
No description provided.