Class: SmartIoC::BeanFileLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_ioc/bean_file_loader.rb

Instance Method Summary collapse

Constructor Details

#initializeBeanFileLoader

Returns a new instance of BeanFileLoader.



2
3
4
5
# File 'lib/smart_ioc/bean_file_loader.rb', line 2

def initialize
  @loaded_locations = {}
  @load_proc        = Proc.new { |location| load(location) }
end

Instance Method Details

#clear_locationsObject



26
27
28
# File 'lib/smart_ioc/bean_file_loader.rb', line 26

def clear_locations
  @loaded_locations = {}
end

#require_bean(bean_name) ⇒ Object

return nil

Parameters:

  • bean_name (Symbol)

    bean name



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/smart_ioc/bean_file_loader.rb', line 14

def require_bean(bean_name)
  locations = SmartIoC::BeanLocations.get_bean_locations(bean_name).values.flatten

  locations.each do |location|
    next if @loaded_locations.has_key?(location)
    @loaded_locations[location] = true
    @load_proc.call(location)
  end

  nil
end

#set_load_proc(&block) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/smart_ioc/bean_file_loader.rb', line 7

def set_load_proc(&block)
  raise ArgumentError, "block should be given" unless block_given?
  @load_proc = block
end