diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-21 22:07:24 +0000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-21 22:17:35 +0000 |
commit | 401393b6561adc1ce7101945163c9601257c057a (patch) | |
tree | 1b5e083d96af5cbafd6914144071158de6236a3d /activesupport/lib | |
parent | f312e2142b59b39637ab3d668876c3babac22087 (diff) | |
download | rails-401393b6561adc1ce7101945163c9601257c057a.tar.gz rails-401393b6561adc1ce7101945163c9601257c057a.tar.bz2 rails-401393b6561adc1ce7101945163c9601257c057a.zip |
Deprecate InstanceMethods namespace handling in ActiveSupport::Concern.
This avoids the unnecessary "yo dawg, I heard you like include, so I put a module that includes your module when it is included" approach when building extensions.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/concern.rb | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb index 81fb859334..af3da937c7 100644 --- a/activesupport/lib/active_support/concern.rb +++ b/activesupport/lib/active_support/concern.rb @@ -4,17 +4,12 @@ module ActiveSupport # module M # def self.included(base) # base.extend ClassMethods - # base.send(:include, InstanceMethods) # scope :disabled, where(:disabled => true) # end # # module ClassMethods # ... # end - # - # module InstanceMethods - # ... - # end # end # # By using <tt>ActiveSupport::Concern</tt> the above module could instead be written as: @@ -31,10 +26,6 @@ module ActiveSupport # module ClassMethods # ... # end - # - # module InstanceMethods - # ... - # end # end # # Moreover, it gracefully handles module dependencies. Given a +Foo+ module and a +Bar+ @@ -118,7 +109,11 @@ module ActiveSupport @_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") + if const_defined?("InstanceMethods") + base.send :include, const_get("InstanceMethods") + ActiveSupport::Deprecation.warn "The InstanceMethods module inside ActiveSupport::Concern will be " \ + "no longer included automatically. Please define instance methods directly in #{base} instead.", caller + end base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block") end end |