Sha256: d777534617c972002fe795604aceea3d40601f30c7bdd3672553fd419082c642

Contents?: true

Size: 1.96 KB

Versions: 67

Compression:

Stored size: 1.96 KB

Contents

require 'active_support/deprecation'

# A deprecated mechanism to mark a class reloadable.
# 
# Deprecated as of Rails 1.2.
# All autoloaded objects are now unloaded.
module Reloadable #:nodoc:
  class << self    
    def included(base) #nodoc:
      unless base.ancestors.include?(Reloadable::Subclasses) # Avoid double warning
        ActiveSupport::Deprecation.warn "Reloadable has been deprecated and has no effect.", caller
      end
      
      raise TypeError, "Only Classes can be Reloadable!" unless base.is_a? Class
      
      unless base.respond_to?(:reloadable?)
        class << base
          define_method(:reloadable?) do
            ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
            true
          end
        end
      end
    end
    
    def reloadable_classes
      ActiveSupport::Deprecation.silence do
        included_in_classes.select { |klass| klass.reloadable? }
      end
    end
    deprecate :reloadable_classes
  end
  
  # Captures the common pattern where a base class should not be reloaded,
  # but its subclasses should be.
  # 
  # Deprecated as of Rails 1.2.
  # All autoloaded objects are now unloaded.
  module Subclasses #:nodoc:
    def self.included(base) #nodoc:
      base.send :include, Reloadable
      ActiveSupport::Deprecation.warn "Reloadable::Subclasses has been deprecated and has no effect.", caller
      (class << base; self; end).send(:define_method, :reloadable?) do
        ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
        base != self
      end
    end
  end
  
  module Deprecated #:nodoc:
    def self.included(base)
      class << base
        define_method(:reloadable?) do
          ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
          true # This might not have the desired effect, as AR::B.reloadable? => true.
        end
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 4 rubygems

Version Path
radiant-0.6.1 vendor/rails/activesupport/lib/active_support/reloadable.rb
radiant-0.6.0 vendor/rails/activesupport/lib/active_support/reloadable.rb
radiant-0.6.3 vendor/rails/activesupport/lib/active_support/reloadable.rb
radiant-0.6.2 vendor/rails/activesupport/lib/active_support/reloadable.rb
radiant-0.6.4 vendor/rails/activesupport/lib/active_support/reloadable.rb
rq-3.3.0 rails/vendor/rails/activesupport/lib/active_support/reloadable.rb
rq-3.4.0 rails/vendor/rails/activesupport/lib/active_support/reloadable.rb