diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-10-13 23:32:32 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-10-13 23:32:32 -0500 |
commit | 7ec947d59c1bc3e9772788b757fe70f51b0ffd9b (patch) | |
tree | 7cf490a36de551ad1200ba8d6f5758043b785096 /activesupport/lib/active_support/concern.rb | |
parent | 7b169ed1bb424929e332e998a75cdb4635c26f62 (diff) | |
download | rails-7ec947d59c1bc3e9772788b757fe70f51b0ffd9b.tar.gz rails-7ec947d59c1bc3e9772788b757fe70f51b0ffd9b.tar.bz2 rails-7ec947d59c1bc3e9772788b757fe70f51b0ffd9b.zip |
Refactor AS concern to avoid hacking the "include" method.
Ruby Magic!
Diffstat (limited to 'activesupport/lib/active_support/concern.rb')
-rw-r--r-- | activesupport/lib/active_support/concern.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb index dcf1e8152f..eb31f7cad4 100644 --- a/activesupport/lib/active_support/concern.rb +++ b/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") @@ -19,7 +25,5 @@ module ActiveSupport super end end - - alias_method :include, :depends_on end end |