Class: BigBrother::ClusterCollection
- Inherits:
-
Object
- Object
- BigBrother::ClusterCollection
- Extended by:
- Forwardable
- Defined in:
- lib/big_brother/cluster_collection.rb
Instance Method Summary collapse
- #config(new_clusters) ⇒ Object
-
#initialize ⇒ ClusterCollection
constructor
A new instance of ClusterCollection.
- #ready_for_check ⇒ Object
- #running ⇒ Object
- #stopped ⇒ Object
Constructor Details
#initialize ⇒ ClusterCollection
Returns a new instance of ClusterCollection.
8 9 10 |
# File 'lib/big_brother/cluster_collection.rb', line 8 def initialize @clusters = {} end |
Instance Method Details
#config(new_clusters) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/big_brother/cluster_collection.rb', line 12 def config(new_clusters) (@clusters.keys - new_clusters.keys).each do |removed_name| @clusters.delete(removed_name).stop_monitoring! end new_clusters.each do |cluster_name, cluster| if @clusters.key?(cluster_name) @clusters[cluster_name] = cluster.incorporate_state(@clusters[cluster_name]) else @clusters[cluster_name] = cluster end end end |
#ready_for_check ⇒ Object
33 34 35 |
# File 'lib/big_brother/cluster_collection.rb', line 33 def ready_for_check @clusters.values.select(&:needs_check?) end |
#running ⇒ Object
25 26 27 |
# File 'lib/big_brother/cluster_collection.rb', line 25 def running @clusters.values.select(&:monitored?) end |
#stopped ⇒ Object
29 30 31 |
# File 'lib/big_brother/cluster_collection.rb', line 29 def stopped @clusters.values.reject(&:monitored?) end |