Last active
September 5, 2019 16:06
-
-
Save bcardarella/5735987 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No worries. If I find out, I'll tell you. And in the meantime: good luck with Lumen! 🙂