Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Last active September 5, 2019 16:06
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcardarella/5735987 to your computer and use it in GitHub Desktop.
Save bcardarella/5735987 to your computer and use it in GitHub Desktop.
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
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
Copy link
Author

@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
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
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