Module: Jtor::Imports

Defined in:
lib/jtor-stdlib/jtor_import.rb

Instance Method Summary collapse

Instance Method Details

#jtor_import(import_string) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/jtor-stdlib/jtor_import.rb', line 3

def jtor_import(import_string)
  packages = import_string.split('.')
  path = File.join(packages[0..-2], "#{packages.last}.rb")
  paths = Dir[path]
  if paths.any?
    paths.each { |p| require File.expand_path(p) }
  else
    java_import import_string
  end
end