Skip to content

Conversation

@kaspermeyer
Copy link

This PR implements support for inheriting hooks defined in ancestors.

A previous PR has also targeted this issue; however, that solution does not support hooks declared in ancestors at runtime. This solution does:

class ParentInteractor
  include Interactor
end

class ChildInteractor < ParentInteractor
end

ParentInteractor.before do
  puts "Before in parent"
end

ChildInteractor.call 
=> "Before in parent"

I had to move around the internals of the Hooks module a bit to make this work, which might break things, should people attempt to mutate the values of #around_hooks, #before_hooks and #after_hooks in their applications. I hope this is acceptable if we target this fix for the next major version, which seems to be 4.0.

Let me know if I'm missing anything.

Fixes: #114

@tsuwatch
Copy link

Could you review this if you get a chance? @gaffneyc @danielmorrison

@vsh91 vsh91 mentioned this pull request Feb 8, 2023
@emilyst
Copy link

emilyst commented Feb 19, 2024

This is really nice, and I'd support seeing this merged as well.

@gaffneyc
Copy link
Member

Sorry that it's taken so long to get eyes on this. I think this looks good and it's tentatively slated for 4.0 since it's a possible breaking change. No word on exactly when that will be but it's something I'm working toward as time permits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Callbacks are not inherited

4 participants