removing log dir from .gitignore
[monkeycharger.git] / vendor / rails / activesupport / lib / active_support / reloadable.rb
blob084bda1ee236d93fb0b22fd45e9a5401e45579d0
1 require 'active_support/deprecation'
3 # A deprecated mechanism to mark a class reloadable.
4
5 # Deprecated as of Rails 1.2.
6 # All autoloaded objects are now unloaded.
7 module Reloadable #:nodoc:
8   class << self    
9     def included(base) #nodoc:
10       unless base.ancestors.include?(Reloadable::Subclasses) # Avoid double warning
11         ActiveSupport::Deprecation.warn "Reloadable has been deprecated and has no effect.", caller
12       end
13       
14       raise TypeError, "Only Classes can be Reloadable!" unless base.is_a? Class
15       
16       unless base.respond_to?(:reloadable?)
17         class << base
18           define_method(:reloadable?) do
19             ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
20             true
21           end
22         end
23       end
24     end
25     
26     def reloadable_classes
27       ActiveSupport::Deprecation.silence do
28         included_in_classes.select { |klass| klass.reloadable? }
29       end
30     end
31     deprecate :reloadable_classes
32   end
33   
34   # Captures the common pattern where a base class should not be reloaded,
35   # but its subclasses should be.
36   # 
37   # Deprecated as of Rails 1.2.
38   # All autoloaded objects are now unloaded.
39   module Subclasses #:nodoc:
40     def self.included(base) #nodoc:
41       base.send :include, Reloadable
42       ActiveSupport::Deprecation.warn "Reloadable::Subclasses has been deprecated and has no effect.", caller
43       (class << base; self; end).send(:define_method, :reloadable?) do
44         ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
45         base != self
46       end
47     end
48   end
49   
50   module Deprecated #:nodoc:
51     def self.included(base)
52       class << base
53         define_method(:reloadable?) do
54           ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
55           true # This might not have the desired effect, as AR::B.reloadable? => true.
56         end
57       end
58     end
59   end
60 end