-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Refactor event name resolving #932
Conversation
@mattwynne I prepared a ruby gem for this: https://github.com/dg-ratiodata/event-bus If you like that approach, it's ready to be move to the |
Thanks @dg-ratiodata. I'm pretty snowed under for the next few weeks so I may not have a chance to grok this code for a while. Don't let that hold you up using the event bus pattern for aruba. |
@mattwynne Ok. I am going to use the |
Pinging @tooky on this as well. |
def handlers_for(event_class) | ||
@handlers[event_class.to_s] ||= [] | ||
end | ||
fail EventNameResolveError, %(Transforming "#{event_id}" into an event name failed for unknown reason.) if event_class.nil? |
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.
I don't see why we need this line - it seems overly defensive. The #transform
method always returns an event type, or raises an exception.
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.
No. Since we support user defined NameResolvers, this is a countermeasure against wrongly implemented "NameResolvers".
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.
We should assume that user-defined NameResolvers will follow the protocol and never return nil. Otherwise we have to clutter up our code.
Having read this, I think that my preferred refactoring (if we're going to bother extracting a resolver at all) would be to extract three strategy objects so that we can do away with the whole case statement. |
Superseded by #933 |
Let's move the discussion here https://github.com/fedux-org/event-bus/pull/4. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
@mattwynne As discussed some weeks ago I finished the refactoring of the
Event::Bus
:context
to show the code behaves in different contexts/situationsMaybe we should really move that event bus thing to a separate library. This would make sharing the code much easier and we could use rubygems + version requirement(s) to make aruba and cucumber depend on the correct interface. WDT? What about
cucumber-ruby-common
or justevent-bus
.