Top Level Namespace

Defined Under Namespace

Modules: ActiveRecord, Rails2Ruby2 Classes: ERB, String

Constant Summary collapse

Config =
RbConfig

Instance Method Summary collapse

Instance Method Details

#when_library_loaded(lib_string, options = {}) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rails2_ruby2/kernel_helpers.rb', line 1

def when_library_loaded(lib_string, options = {})
  version_file = options.fetch(:version_file, nil)
  lib_const_string = options.fetch(:lib_const_string, lib_string)

  begin
    Object.const_get(lib_string)
  rescue NameError
    return
  end

  if version_file
    begin
      require(version_file)
    rescue MissingSourceFile
      return
    end
  end

  if Object.const_get(lib_const_string).const_get('VERSION').const_get('MAJOR') == 2
    yield
  end
end