Methods
Public Instance methods
breakpoint()
    # File activesupport/lib/active_support/core_ext/kernel/debugger.rb, line 11
11:   def breakpoint
12:     message = "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n"
13:     defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
14:     debugger
15:   end
class_eval(*args, &block)

class_eval on an object acts like singleton_class.class_eval.

    # File activesupport/lib/active_support/core_ext/kernel/singleton_class.rb, line 10
10:   def class_eval(*args, &block)
11:     singleton_class.class_eval(*args, &block)
12:   end
daemonize()

Turns the current script into a daemon process that detaches from the console. It can be shut down with a TERM signal.

   # File activesupport/lib/active_support/core_ext/kernel/daemonizing.rb, line 4
4:   def daemonize
5:     Process.daemon
6:   end
debugger()

Starts a debugging session if ruby-debug has been loaded (call script/server —debugger to do load it).

   # File activesupport/lib/active_support/core_ext/kernel/debugger.rb, line 4
4:     def debugger
5:       message = "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n"
6:       defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
7:     end
enable_warnings() {|| ...}

Sets $VERBOSE to true for the duration of the block and back to its original value afterwards.

    # File activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 17
17:   def enable_warnings
18:     old_verbose, $VERBOSE = $VERBOSE, true
19:     yield
20:   ensure
21:     $VERBOSE = old_verbose
22:   end
require_library_or_gem(library_name)

Require a library with fallback to RubyGems. Warnings during library loading are silenced to increase signal/noise for application warnings.

    # File activesupport/lib/active_support/core_ext/kernel/requires.rb, line 4
 4:   def require_library_or_gem(library_name)
 5:     silence_warnings do
 6:       begin
 7:         require library_name
 8:       rescue LoadError => cannot_require
 9:         # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
10:         begin
11:           require 'rubygems'
12:         rescue LoadError => rubygems_not_installed
13:           raise cannot_require
14:         end
15:         # 2. Rubygems is installed and loaded. Try to load the library again
16:         begin
17:           require library_name
18:         rescue LoadError => gem_not_installed
19:           raise cannot_require
20:         end
21:       end
22:     end
23:   end
silence_stream(stream) {|| ...}

Silences any stream for the duration of the block.

  silence_stream(STDOUT) do
    puts 'This will never be seen'
  end

  puts 'But this will'
    # File activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 36
36:   def silence_stream(stream)
37:     old_stream = stream.dup
38:     stream.reopen(RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'NUL:' : '/dev/null')
39:     stream.sync = true
40:     yield
41:   ensure
42:     stream.reopen(old_stream)
43:   end
silence_warnings() {|| ...}

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
    # File activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 9
 9:   def silence_warnings
10:     old_verbose, $VERBOSE = $VERBOSE, nil
11:     yield
12:   ensure
13:     $VERBOSE = old_verbose
14:   end
singleton_class()

Returns the object‘s singleton class.

   # File activesupport/lib/active_support/core_ext/kernel/singleton_class.rb, line 3
3:   def singleton_class
4:     class << self
5:       self
6:     end
7:   end
suppress(*exception_classes) {|| ...}

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"
    # File activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 53
53:   def suppress(*exception_classes)
54:     begin yield
55:     rescue Exception => e
56:       raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
57:     end
58:   end