Skip to content

Commit

Permalink
Refactor AS concern to avoid hacking the "include" method.
Browse files Browse the repository at this point in the history
Ruby Magic!
  • Loading branch information
josh committed Oct 14, 2009
1 parent 7b169ed commit 7ec947d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
1 change: 0 additions & 1 deletion activesupport/lib/active_support/autoload.rb
Expand Up @@ -7,7 +7,6 @@ module ActiveSupport
autoload :Callbacks, 'active_support/callbacks'
autoload :Concern, 'active_support/concern'
autoload :ConcurrentHash, 'active_support/concurrent_hash'
autoload :DependencyModule, 'active_support/dependency_module'
autoload :DeprecatedCallbacks, 'active_support/deprecated_callbacks'
autoload :Deprecation, 'active_support/deprecation'
autoload :Gzip, 'active_support/gzip'
Expand Down
16 changes: 10 additions & 6 deletions activesupport/lib/active_support/concern.rb
@@ -1,11 +1,17 @@
require 'active_support/dependency_module'

module ActiveSupport
module Concern
include DependencyModule
def self.extended(base)
base.instance_variable_set("@_dependencies", [])
end

def append_features(base)
if super
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")
base.send :include, const_get("InstanceMethods") if const_defined?("InstanceMethods")
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
Expand All @@ -19,7 +25,5 @@ def included(base = nil, &block)
super
end
end

alias_method :include, :depends_on
end
end
17 changes: 0 additions & 17 deletions activesupport/lib/active_support/dependency_module.rb

This file was deleted.

0 comments on commit 7ec947d

Please sign in to comment.