included do |mod| ... end
としてincludeされたモジュールの情報を使いたい。
This file contains 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 | |
module Concern | |
def append_features(base) | |
if base.instance_variable_defined?("@_dependencies") | |
base.instance_variable_get("@_dependencies") << self | |
return false | |
else | |
return false if base < self | |
@_dependencies.each { |dep| base.send(:include, dep) } | |
super | |
base.extend const_get("ClassMethods") if const_defined?("ClassMethods") | |
if instance_variable_defined?("@_included_block") | |
if @_included_block.is_a? Array | |
base.class_exec(@_included_block[0], &@_included_block[1]) # give module as first argument | |
else | |
base.class_exec(&@_included_block) | |
end | |
end | |
end | |
end | |
def included(base = nil, &block) | |
if base.nil? | |
@_included_block = [self, block] # store module (= self) | |
else | |
super | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment