Module: Kernel
- Defined in:
 - lib/active_support/core_ext/kernel/concern.rb,
lib/active_support/core_ext/kernel/reporting.rb,
lib/active_support/core_ext/kernel/singleton_class.rb 
Class Method Summary collapse
- 
  
    
      .concern(topic, &module_definition)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
A shortcut to define a toplevel concern, not within a module.
 - 
  
    
      .enable_warnings(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets $VERBOSE to
truefor the duration of the block and back to its original value afterwards. - 
  
    
      .silence_warnings(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets $VERBOSE to
nilfor the duration of the block and back to its original value afterwards. - 
  
    
      .suppress(*exception_classes)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Blocks and ignores any exception passed as argument if raised within the block.
 - 
  
    
      .with_warnings(flag)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Sets $VERBOSE for the duration of the block and back to its original value afterwards.
 
Instance Method Summary collapse
- 
  
    
      #class_eval(*args, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
class_eval on an object acts like
singleton_class.class_eval. 
Class Method Details
.concern(topic, &module_definition) ⇒ Object
A shortcut to define a toplevel concern, not within a module.
See Module::Concerning for more.
      11 12 13  | 
    
      # File 'lib/active_support/core_ext/kernel/concern.rb', line 11 def concern(topic, &module_definition) Object.concern topic, &module_definition end  | 
  
.enable_warnings(&block) ⇒ Object
Sets $VERBOSE to true for the duration of the block and back to its original value afterwards.
      20 21 22  | 
    
      # File 'lib/active_support/core_ext/kernel/reporting.rb', line 20 def enable_warnings(&block) with_warnings(true, &block) end  | 
  
.silence_warnings(&block) ⇒ Object
Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.
silence_warnings do
  value = noisy_call # no warning voiced
end
noisy_call # warning voiced
  
      14 15 16  | 
    
      # File 'lib/active_support/core_ext/kernel/reporting.rb', line 14 def silence_warnings(&block) with_warnings(nil, &block) end  | 
  
.suppress(*exception_classes) ⇒ Object
Blocks and ignores any exception passed as argument if raised within the block.
suppress(ZeroDivisionError) do
  1/0
  puts 'This code is NOT reached'
end
puts 'This code gets executed and nothing related to ZeroDivisionError was seen'
  
      41 42 43 44  | 
    
      # File 'lib/active_support/core_ext/kernel/reporting.rb', line 41 def suppress(*exception_classes) yield rescue *exception_classes end  | 
  
.with_warnings(flag) ⇒ Object
Sets $VERBOSE for the duration of the block and back to its original value afterwards.
      26 27 28 29 30 31  | 
    
      # File 'lib/active_support/core_ext/kernel/reporting.rb', line 26 def with_warnings(flag) old_verbose, $VERBOSE = $VERBOSE, flag yield ensure $VERBOSE = old_verbose end  | 
  
Instance Method Details
#class_eval(*args, &block) ⇒ Object
class_eval on an object acts like singleton_class.class_eval.
      5 6 7  | 
    
      # File 'lib/active_support/core_ext/kernel/singleton_class.rb', line 5 def class_eval(*args, &block) singleton_class.class_eval(*args, &block) end  |