Class: SSHKit::Coordinator

Inherits:
Object
  • Object
show all
Defined in:
lib/sshkit/coordinator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_hosts) ⇒ Coordinator

Returns a new instance of Coordinator.



7
8
9
10
# File 'lib/sshkit/coordinator.rb', line 7

def initialize(raw_hosts)
  @raw_hosts = Array(raw_hosts)
  @hosts = @raw_hosts.any? ? resolve_hosts : []
end

Instance Attribute Details

#hostsObject

Returns the value of attribute hosts.



5
6
7
# File 'lib/sshkit/coordinator.rb', line 5

def hosts
  @hosts
end

Instance Method Details

#each(options = {}, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sshkit/coordinator.rb', line 12

def each(options={}, &block)
  if hosts
    options = default_options.merge(options)
    case options[:in]
    when :parallel then Runner::Parallel
    when :sequence then Runner::Sequential
    when :groups   then Runner::Group
    else
      options[:in]
    end.new(hosts, options, &block).execute
  else
    Runner::Null.new(hosts, options, &block).execute
  end
end