Class: ActiveSupport::Deprecation::Deprecators
- Defined in:
 - lib/active_support/deprecation/deprecators.rb
 
Overview
A managed collection of deprecators. Configuration methods, such as #behavior=, affect all deprecators in the collection. Additionally, the #silence method silences all deprecators in the collection for the duration of a given block.
Instance Method Summary collapse
- 
  
    
      #[](name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a deprecator added to this collection via #[]=.
 - 
  
    
      #[]=(name, deprecator)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Adds a given
deprecatorto this collection. - 
  
    
      #behavior=(behavior)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets the deprecation warning behavior for all deprecators in this collection.
 - 
  
    
      #debug=(debug)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets the debug flag for all deprecators in this collection.
 - 
  
    
      #disallowed_behavior=(disallowed_behavior)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets the disallowed deprecation warning behavior for all deprecators in this collection.
 - 
  
    
      #disallowed_warnings=(disallowed_warnings)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets the disallowed deprecation warnings for all deprecators in this collection.
 - 
  
    
      #each(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Iterates over all deprecators in this collection.
 - 
  
    
      #initialize  ⇒ Deprecators 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Deprecators.
 - 
  
    
      #silence(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Silences all deprecators in this collection for the duration of the given block.
 - 
  
    
      #silenced=(silenced)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets the silenced flag for all deprecators in this collection.
 
Constructor Details
#initialize ⇒ Deprecators
Returns a new instance of Deprecators.
      10 11 12 13  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 10 def initialize @options = {} @deprecators = {} end  | 
  
Instance Method Details
#[](name) ⇒ Object
Returns a deprecator added to this collection via #[]=.
      16 17 18  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 16 def [](name) @deprecators[name] end  | 
  
#[]=(name, deprecator) ⇒ Object
Adds a given deprecator to this collection. The deprecator will be immediately configured with any options previously set on this collection.
deprecators = ActiveSupport::Deprecation::Deprecators.new
deprecators.debug = true
foo_deprecator = ActiveSupport::Deprecation.new("2.0", "Foo")
foo_deprecator.debug    # => false
deprecators[:foo] = foo_deprecator
deprecators[:foo].debug # => true
foo_deprecator.debug    # => true
  
      34 35 36 37  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 34 def []=(name, deprecator) (deprecator) @deprecators[name] = deprecator end  | 
  
#behavior=(behavior) ⇒ Object
Sets the deprecation warning behavior for all deprecators in this collection.
See ActiveSupport::Deprecation#behavior=.
      60 61 62  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 60 def behavior=(behavior) set_option(:behavior, behavior) end  | 
  
#debug=(debug) ⇒ Object
Sets the debug flag for all deprecators in this collection.
      52 53 54  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 52 def debug=(debug) set_option(:debug, debug) end  | 
  
#disallowed_behavior=(disallowed_behavior) ⇒ Object
Sets the disallowed deprecation warning behavior for all deprecators in this collection.
See ActiveSupport::Deprecation#disallowed_behavior=.
      68 69 70  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 68 def disallowed_behavior=(disallowed_behavior) set_option(:disallowed_behavior, disallowed_behavior) end  | 
  
#disallowed_warnings=(disallowed_warnings) ⇒ Object
Sets the disallowed deprecation warnings for all deprecators in this collection.
See ActiveSupport::Deprecation#disallowed_warnings=.
      76 77 78  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 76 def disallowed_warnings=(disallowed_warnings) set_option(:disallowed_warnings, disallowed_warnings) end  | 
  
#each(&block) ⇒ Object
Iterates over all deprecators in this collection. If no block is given, returns an Enumerator.
      41 42 43 44  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 41 def each(&block) return to_enum(__method__) unless block @deprecators.each_value(&block) end  | 
  
#silence(&block) ⇒ Object
Silences all deprecators in this collection for the duration of the given block.
See ActiveSupport::Deprecation#silence.
      84 85 86 87 88 89  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 84 def silence(&block) each { |deprecator| deprecator.begin_silence } block.call ensure each { |deprecator| deprecator.end_silence } end  | 
  
#silenced=(silenced) ⇒ Object
Sets the silenced flag for all deprecators in this collection.
      47 48 49  | 
    
      # File 'lib/active_support/deprecation/deprecators.rb', line 47 def silenced=(silenced) set_option(:silenced, silenced) end  |