Create a gist now

Instantly share code, notes, and snippets.

included do |mod| ... end としてincludeされたモジュールの情報を使いたい。
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