diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-02-02 06:11:37 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-02-02 06:11:37 +0000 |
commit | 52b04e8e7417719128e0882cdd4356882af6556a (patch) | |
tree | 4d3bd91a8898a174fc2df0aab67305becdd64626 /activesupport | |
parent | 1bce58b31289362d62863ad0600b924858a11e34 (diff) | |
download | rails-52b04e8e7417719128e0882cdd4356882af6556a.tar.gz rails-52b04e8e7417719128e0882cdd4356882af6556a.tar.bz2 rails-52b04e8e7417719128e0882cdd4356882af6556a.zip |
Reloadable::OnlySubclasses
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3522 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/reloadable.rb | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index b2dfa0744c..bd001f3196 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add documentation for Reloadable::OnlySubclasses. [Nicholas Seckar] + * Add Reloadable::OnlySubclasses which handles the common case where a base class should not be reloaded, but its subclasses should be. [Nicholas Seckar] * Further improvements to reloading code [Nicholas Seckar, Trevor Squires] diff --git a/activesupport/lib/active_support/reloadable.rb b/activesupport/lib/active_support/reloadable.rb index 7749f0b165..179e04a0fe 100644 --- a/activesupport/lib/active_support/reloadable.rb +++ b/activesupport/lib/active_support/reloadable.rb @@ -15,13 +15,13 @@ module Reloadable end end + # Captures the common pattern where a base class should not be reloaded, + # but its subclasses should be. module OnlySubclasses - class << self - def included(base) #nodoc: - base.send :include, Reloadable - (class << base; self; end;).class_eval do - define_method(:reloadable?) { self != base } - end + def self.included(base) #nodoc: + base.send :include, Reloadable + (class << base; self; end).send(:define_method, :reloadable?) do + base != self end end end |