Module: SmartIoC

Extended by:
Forwardable
Defined in:
lib/smart_ioc.rb,
lib/smart_ioc/version.rb,
lib/smart_ioc/container.rb,
lib/smart_ioc/string_utils.rb

Defined Under Namespace

Modules: Args, Errors, Iocify, Scopes Classes: BeanDefinition, BeanDefinitionsStorage, BeanDependency, BeanFactory, BeanFileLoader, BeanLocations, BeanLocator, Container, ExtraPackageContexts, InjectMetadata, Railtie, StringUtils

Constant Summary collapse

VERSION =
"0.5.2"

Class Method Summary collapse

Class Method Details

.benchmark_mode(flag) ⇒ Object



57
58
59
# File 'lib/smart_ioc.rb', line 57

def benchmark_mode(flag)
  @benchmark_mode = !!flag
end

.clearObject

Full clear of data (mostly for tests)



69
70
71
72
# File 'lib/smart_ioc.rb', line 69

def clear
  BeanLocations.clear
  Container.clear
end

.containerObject



74
75
76
# File 'lib/smart_ioc.rb', line 74

def container
  Container.get_instance
end

.find_package_beans(package_name, dir) ⇒ Object

Returns nil.

Parameters:

  • package_name (String or Symbol)

    package name for bean definitions

  • dir (String)

    absolute path with bean definitions

Returns:

  • nil



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/smart_ioc.rb', line 42

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_modeObject



35
36
37
# File 'lib/smart_ioc.rb', line 35

def is_benchmark_mode
  @benchmark_mode
end

.load_all_beansObject

Load all beans (usually required for production env)



62
63
64
65
66
# File 'lib/smart_ioc.rb', line 62

def load_all_beans
  BeanLocations.all_bean_names.each do |bean|
    container.require_bean(bean)
  end
end