Skip to content

Instantly share code, notes, and snippets.

@bcardarella bcardarella/concern.rb

Last active Sep 5, 2019
Embed
What would you like to do?
module ActiveSupport::Concern
def append_features(base)
if base.instance_variable_defined?("@_dependencies")
base.instance_variable_get("@_dependencies") << { :module => self, :method => :include }
return false
else
return false if base < self
@_dependencies.each { |dep| base.send(dep[:method], dep[:module]) }
super
base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
end
end
def prepend_features(base)
if base.instance_variable_defined?("@_dependencies")
base.instance_variable_get("@_dependencies").unshift({ :module => self, :method => :prepend })
return false
else
return false if base < self
super
base.singleton_class.send(:prepend, const_get('ClassMethods'))
@_dependencies.each { |dep| base.send(dep[:method], dep[:module]) }
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
end
end
alias_method :prepended, :included
end
@Qqwy

This comment has been minimized.

Copy link

Qqwy commented Sep 5, 2019

Thank you for making this!

Unfortunately, in Rails 5 this seems to be no longer working. I have not yet found out what has to be changed to fix it.

@bcardarella

This comment has been minimized.

Copy link
Owner Author

bcardarella commented Sep 5, 2019

@Qqwy thanks but I haven't used Rails in many year so I cannot say how to adapt to the current iteration of the framework. Sorry!

@Qqwy

This comment has been minimized.

Copy link

Qqwy commented Sep 5, 2019

No worries. If I find out, I'll tell you. And in the meantime: good luck with Lumen! 🙂

@Qqwy

This comment has been minimized.

Copy link

Qqwy commented Sep 5, 2019

I believe that the slightly different version that is part of easy_auth still works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.