Class: Rigger::ServerResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/rigger/server_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ServerResolver

Returns a new instance of ServerResolver



3
4
5
# File 'lib/rigger/server_resolver.rb', line 3

def initialize(config)
  @config = config
end

Instance Method Details

#call(task) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rigger/server_resolver.rb', line 7

def call(task)
  roles = [*task.options[:role]].compact
  only  = task.options.fetch(:only, {})

  role_servers = roles.empty? ? @config.servers : from_roles(roles)
  only_servers = only.empty?  ? @config.servers : from_only(only)

  (role_servers & only_servers)
end