Module: WillPaginate::Deprecation
- Defined in:
- lib/will_paginate/deprecation.rb
Constant Summary collapse
- 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 Method Summary collapse
-
.behavior ⇒ Object
Behavior is a block that takes a message argument.
- .behavior=(value) ⇒ Object
- .debug ⇒ Object
- .debug=(value) ⇒ Object
- .default_behavior ⇒ Object
- .silence ⇒ Object
- .warn(message, callstack = caller) ⇒ Object
Class Method Details
.behavior ⇒ Object
Behavior is a block that takes a message argument.
38 |
# File 'lib/will_paginate/deprecation.rb', line 38 def self.behavior() @behavior; end |
.behavior=(value) ⇒ Object
39 |
# File 'lib/will_paginate/deprecation.rb', line 39 def self.behavior=(value) @behavior = value; end |
.debug ⇒ Object
4 |
# File 'lib/will_paginate/deprecation.rb', line 4 def self.debug() @debug; end |
.debug=(value) ⇒ Object
5 |
# File 'lib/will_paginate/deprecation.rb', line 5 def self.debug=(value) @debug = value; end |
.default_behavior ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/will_paginate/deprecation.rb', line 29 def self.default_behavior if defined?(RAILS_ENV) BEHAVIORS[RAILS_ENV.to_s] else BEHAVIORS['test'] end end |
.silence ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/will_paginate/deprecation.rb', line 42 def self.silence old_behavior = self.behavior self.behavior = nil yield ensure self.behavior = old_behavior end |
.warn(message, callstack = caller) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/will_paginate/deprecation.rb', line 22 def self.warn(, callstack = caller) if behavior = 'WillPaginate: ' + .strip.gsub(/\s+/, ' ') behavior.call(, callstack) end end |