-
Notifications
You must be signed in to change notification settings - Fork 142
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
Be able to pass in a model that isn't strictly a certain class #169
Comments
As a hack that's perhaps a bit cleaner you can specify the class of the model to be a common ancestor of the two. class ChangeBankAccountInteraction < ActiveInteraction::Base
model :bank_accountable, class: Object
...
end It seems like what you really want is an interface check. We've discussed the possibility of doing that but we do not currently have it on our roadmap. |
The model filter should gracefully handle concerns out of the box. module Concern
extend ActiveSupport::Concern
end
class Model
include Concern
end
class Interaction < ActiveInteraction::Base
model :concern
def execute
inputs
end
end
Interaction.run!(concern: Model.new)
# => {:concern=>#<Model:0x007ff22e944d50>} |
Right, the included modules act as ancestors so the check works. Tada, we do support it! |
Woohoo! I should've thought about trying that, argh. Is this a good time to say ActiveInteraction rocks? Seriously, my socks are off. Keep up the great work guys, thanks! |
We work with concerns, a lot, and we constantly need to pass in a variety of models that share the same concern into an interaction, but it appears that only
model
is supported and it seems to complain if it isn't a specific class that's passed in. So far how we are doing it is:but this is cringe worthy. Is there a recommended way to do this or any plans to support it?
The text was updated successfully, but these errors were encountered: