Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Refactor event name resolving #932

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 12, 2015

@mattwynne As discussed some weeks ago I finished the refactoring of the Event::Bus:

  • Added more tests for Bus + NameResolver
  • Refactored the the test suite to make use of context to show the code behaves in different contexts/situations

Maybe 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 just event-bus.

@ghost
Copy link
Author

ghost commented Nov 12, 2015

@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 cucumber-organization.

@ghost ghost mentioned this pull request Nov 13, 2015
@ghost
Copy link
Author

ghost commented Nov 13, 2015

I prepared a PR to integrate the gem instead of the changes made in this PR. Either #932 or #933 should be merged.

@mattwynne
Copy link
Member

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.

@maxmeyer
Copy link
Member

@mattwynne Ok. I am going to use the gem for aruba.

@ghost
Copy link
Author

ghost commented Nov 16, 2015

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?
Copy link
Member

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.

Copy link
Author

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".

Copy link
Member

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.

@mattwynne
Copy link
Member

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.

@mattwynne mattwynne closed this Jan 8, 2016
@mattwynne
Copy link
Member

Superseded by #933

@ghost
Copy link
Author

ghost commented Jan 8, 2016

Let's move the discussion here https://github.com/fedux-org/event-bus/pull/4.

@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants