Class: SmartIoC::BeanFileLoader
- Inherits:
-
Object
- Object
- SmartIoC::BeanFileLoader
- Defined in:
- lib/smart_ioc/bean_file_loader.rb
Instance Method Summary collapse
- #clear_locations ⇒ Object
-
#initialize ⇒ BeanFileLoader
constructor
A new instance of BeanFileLoader.
-
#require_bean(bean_name) ⇒ Object
return nil.
- #set_load_proc(&block) ⇒ Object
Constructor Details
#initialize ⇒ BeanFileLoader
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_locations ⇒ Object
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
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
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 |