Sha256: 9dce291345a9916ea14168d50a3834f9e0e83f89f82ca9dd148563dcbc4969e5

Contents?: true

Size: 683 Bytes

Versions: 18

Compression:

Stored size: 683 Bytes

Contents

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

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

  # @param bean_name [Symbol] bean name
  # return nil
  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

  def clear_locations
    @loaded_locations = {}
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
smart_ioc-0.5.2 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.5.1 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.5.0 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.9 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.4.0 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.8 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.7 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.6 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.5 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.2 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.1 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.3.0 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.2.5 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.2.4 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.2.3 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.2.2 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.2.1 lib/smart_ioc/bean_file_loader.rb
smart_ioc-0.2.0 lib/smart_ioc/bean_file_loader.rb