Class: SwitchTower::Actor::Task
- Inherits:
-
Object
- Object
- SwitchTower::Actor::Task
- Defined in:
- lib/switchtower/actor.rb
Overview
Represents the definition of a single task.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
:nodoc:.
-
#options ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#initialize(name, options) ⇒ Task
constructor
A new instance of Task.
-
#servers(configuration) ⇒ Object
Returns the list of servers (not connections to servers) that are the target of this task.
Constructor Details
#initialize(name, options) ⇒ Task
Returns a new instance of Task.
64 65 66 |
# File 'lib/switchtower/actor.rb', line 64 def initialize(name, ) @name, @options = name, end |
Instance Attribute Details
#name ⇒ Object (readonly)
:nodoc:
62 63 64 |
# File 'lib/switchtower/actor.rb', line 62 def name @name end |
#options ⇒ Object (readonly)
:nodoc:
62 63 64 |
# File 'lib/switchtower/actor.rb', line 62 def @options end |
Instance Method Details
#servers(configuration) ⇒ Object
Returns the list of servers (not connections to servers) that are the target of this task.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/switchtower/actor.rb', line 70 def servers(configuration) unless @servers roles = [*(@options[:roles] || configuration.roles.keys)].map { |name| configuration.roles[name] or raise ArgumentError, "task #{self.name.inspect} references non-existant role #{name.inspect}" }.flatten only = @options[:only] || {} unless only.empty? roles = roles.delete_if do |role| catch(:done) do only.keys.each do |key| throw(:done, true) if role.[key] != only[key] end false end end end @servers = roles.map { |role| role.host }.uniq end @servers end |