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

Callbacks are not inherited #114

Open
aldesantis opened this issue Aug 13, 2016 · 6 comments · May be fixed by #191
Open

Callbacks are not inherited #114

aldesantis opened this issue Aug 13, 2016 · 6 comments · May be fixed by #191
Assignees
Labels
Milestone

Comments

@aldesantis
Copy link

aldesantis commented Aug 13, 2016

I'm rewriting my API layer to use interactors and I noticed callbacks defined on an interactor are not inherited by its children. Is this the desired behavior?

For the moment, this works fine:

class ParentInteractor
  def self.inherited(klass)
    klass.class_eval do
      # my hooks
    end
  end
end
@laserlemon
Copy link
Collaborator

Could you write a test to expose this issue?

@laserlemon laserlemon added this to the v4.0.0 milestone Mar 22, 2017
@laserlemon laserlemon added the bug label Mar 22, 2017
@aandis
Copy link

aandis commented Feb 21, 2018

I can confirm inheritance doesn't work on hooks. Any update on the fix?

@manojmj92
Copy link

@aandis There are no updates on this from maintainers. But just yesterday, we solved this problem at our company using the method mentioned in the PR description (using inherited hooks) and it works well :)

@att14
Copy link

att14 commented Mar 8, 2018

Here is a test case:

require 'interactor'

class ABC
  include Interactor

  around :do_it

  def do_it(interactor)
    p "doing it"
    interactor.call
    p "done it"
  end
end

class DoIt < ABC
  def call
    p "calling DoIt"
  end
end

DoIt.call

class DoItAgain < ABC
  around :do_it

  def call
    p "calling DoItAgain"
  end
end

DoItAgain.call

Output:

"calling DoIt"
"doing it"
"calling DoItAgain"
"done it"

Expected Output:

"doing it"
"calling DoIt"
"done it"
"doing it"
"calling DoItAgain"
"done it"

Gemfile used:

source "https://rubygems.org"

gem "interactor"

@iMacTia
Copy link

iMacTia commented Oct 7, 2020

+1, still an issue on the latest version 😕

@vitork
Copy link

vitork commented Apr 11, 2023

Still an issue 7 years later...

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 a pull request may close this issue.

7 participants