Module: ActiveSupport::Deprecation
- Defined in:
- lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Assertions, ClassMethods Classes: DeprecatedConstantProxy, DeprecatedInstanceVariableProxy, DeprecatedObjectProxy, DeprecationProxy
Constant Summary collapse
- DEFAULT_BEHAVIORS =
Choose the default warn behavior according to RAILS_ENV. Ignore deprecation warnings in production.
{ 'test' => Proc.new { |, callstack| $stderr.puts() $stderr.puts callstack.join("\n ") if debug }, 'development' => Proc.new { |, callstack| logger = defined?(::RAILS_DEFAULT_LOGGER) ? ::RAILS_DEFAULT_LOGGER : Logger.new($stderr) logger.warn logger.debug callstack.join("\n ") if debug } }
Class Attribute Summary collapse
-
.silenced ⇒ Object
writeonly
Sets the attribute silenced.
Class Method Summary collapse
- .default_behavior ⇒ Object
-
.silence ⇒ Object
Silence deprecation warnings within the block.
-
.silenced? ⇒ Boolean
Have deprecations been silenced?.
- .warn(message = nil, callstack = caller) ⇒ Object
Class Attribute Details
.silenced=(value) ⇒ Object (writeonly)
Sets the attribute silenced
49 50 51 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb', line 49 def silenced=(value) @silenced = value end |
Class Method Details
.default_behavior ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb', line 27 def default_behavior if defined?(RAILS_ENV) DEFAULT_BEHAVIORS[RAILS_ENV.to_s] else DEFAULT_BEHAVIORS['test'] end end |
.silence ⇒ Object
Silence deprecation warnings within the block.
42 43 44 45 46 47 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb', line 42 def silence old_silenced, @silenced = @silenced, true yield ensure @silenced = old_silenced end |
.silenced? ⇒ Boolean
Have deprecations been silenced?
36 37 38 39 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb', line 36 def silenced? @silenced = false unless defined?(@silenced) @silenced end |
.warn(message = nil, callstack = caller) ⇒ Object
23 24 25 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb', line 23 def warn( = nil, callstack = caller) behavior.call((callstack, ), callstack) if behavior && !silenced? end |