Class: AutomateEm::Modules
- Inherits:
-
Object
- Object
- AutomateEm::Modules
- Defined in:
- lib/automate-em/core/modules.rb
Constant Summary collapse
- @@modules =
modules (dependency_id => module class)
{}
- @@load_lock =
Mutex.new
Object.new.extend(MonitorMixin)
- @@loading =
nil
Class Method Summary collapse
Class Method Details
.[](dep_id) ⇒ Object
7 8 9 10 11 |
# File 'lib/automate-em/core/modules.rb', line 7 def self.[] (dep_id) @@load_lock.mon_synchronize { @@modules[dep_id] } end |
.load_module(dep) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/automate-em/core/modules.rb', line 13 def self.load_module(dep) @@load_lock.mon_synchronize { begin found = false file = "#{dep.classname.underscore}.rb" Rails.configuration.automate.module_paths.each do |path| if File.exists?("#{path}/#{file}") load "#{path}/#{file}" found = true break end end if not found raise "File not found! (#{file})" end @@modules[dep.id] = dep.classname.constantize rescue => e AutomateEm.print_error(System.logger, e, { :message => "device module #{dep.actual_name} error whilst loading", :level => Logger::ERROR }) end } end |