Class: Orchestrator::System
- Inherits:
-
Object
- Object
- Orchestrator::System
- Defined in:
- lib/orchestrator/system.rb
Constant Summary collapse
- @@systems =
ThreadSafe::Cache.new
- @@critical =
Mutex.new
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#zones ⇒ Object
readonly
Returns the value of attribute zones.
Class Method Summary collapse
Instance Method Summary collapse
- #all(mod) ⇒ Object
- #count(name) ⇒ Object
- #get(mod, index) ⇒ Object
-
#initialize(control_system) ⇒ System
constructor
A new instance of System.
- #modules ⇒ Object
- #settings ⇒ Object
Constructor Details
#initialize(control_system) ⇒ System
Returns a new instance of System.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/orchestrator/system.rb', line 32 def initialize(control_system) @config = control_system @controller = ::Orchestrator::Control.instance @modules = {} @config.modules.each &method(:index_module) # Build an ordered zone cache for setting lookup zones = ::Orchestrator::Control.instance.zones @zones = [] @config.zones.each do |zone_id| zone = zones[zone_id] @zones << zone unless zone.nil? end # Inform status tracker that that the system has reloaded # There may have been a change in module order etc @controller.threads.each do |thread| thread.next_tick do thread.observer.reloaded_system(@config.id, self) end end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
29 30 31 |
# File 'lib/orchestrator/system.rb', line 29 def config @config end |
#zones ⇒ Object (readonly)
Returns the value of attribute zones.
29 30 31 |
# File 'lib/orchestrator/system.rb', line 29 def zones @zones end |
Class Method Details
.clear_cache ⇒ Object
22 23 24 25 26 |
# File 'lib/orchestrator/system.rb', line 22 def self.clear_cache @@critical.synchronize { @@systems = ThreadSafe::Cache.new } end |
.expire(id) ⇒ Object
18 19 20 |
# File 'lib/orchestrator/system.rb', line 18 def self.expire(id) @@systems.delete(id.to_sym) end |
.get(id) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/orchestrator/system.rb', line 9 def self.get(id) name = id.to_sym system = @@systems[name] if system.nil? system = self.load(name) end return system end |
Instance Method Details
#all(mod) ⇒ Object
65 66 67 |
# File 'lib/orchestrator/system.rb', line 65 def all(mod) @modules[mod] || [] end |
#count(name) ⇒ Object
69 70 71 72 |
# File 'lib/orchestrator/system.rb', line 69 def count(name) mod = @modules[name.to_sym] mod.nil? ? 0 : mod.length end |
#get(mod, index) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/orchestrator/system.rb', line 56 def get(mod, index) mods = @modules[mod] if mods mods[index] else nil # As subscriptions can be made to modules that don't exist end end |
#modules ⇒ Object
74 75 76 |
# File 'lib/orchestrator/system.rb', line 74 def modules @modules.keys end |
#settings ⇒ Object
78 79 80 |
# File 'lib/orchestrator/system.rb', line 78 def settings @config.settings end |