module SmartIoC

Constants

VERSION

Public Class Methods

benchmark_mode(flag) click to toggle source
# File lib/smart_ioc.rb, line 56
def benchmark_mode(flag)
  @benchmark_mode = !!flag
end
clear() click to toggle source

Full clear of data (mostly for tests)

# File lib/smart_ioc.rb, line 68
def clear
  BeanLocations.clear
  Container.clear
end
container() click to toggle source
# File lib/smart_ioc.rb, line 73
def container
  Container.get_instance
end
find_package_beans(package_name, dir) click to toggle source

@param package_name [String or Symbol] package name for bean definitions @param dir [String] absolute path with bean definitions @return nil

# File lib/smart_ioc.rb, line 41
def find_package_beans(package_name, dir)
  time = Benchmark.realtime do
    bean_locator = SmartIoC::BeanLocator.new
    bean_locator.locate_beans(package_name.to_sym, dir)
  end

  time *= 1000

  if is_benchmark_mode
    puts "Search finished for '#{package_name}'. Time taken: #{"%.2f ms" % time}"
  end

  nil
end
is_benchmark_mode() click to toggle source
# File lib/smart_ioc.rb, line 34
def is_benchmark_mode
  @benchmark_mode
end
load_all_beans() click to toggle source

Load all beans (usually required for production env)

# File lib/smart_ioc.rb, line 61
def load_all_beans
  BeanLocations.all_bean_names.each do |bean|
    container.require_bean(bean)
  end
end