Class: Ey::Core::Cli::Helpers::ServerSieve

Inherits:
Object
  • Object
show all
Defined in:
lib/ey-core/cli/helpers/server_sieve.rb

Constant Summary collapse

ROLES =
[
  :app_servers,
  :db_servers,
  :app_master,
  :db_master,
  :utilities
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(servers_api, options = {}) ⇒ ServerSieve

Returns a new instance of ServerSieve.



20
21
22
23
# File 'lib/ey-core/cli/helpers/server_sieve.rb', line 20

def initialize(servers_api, options = {})
  @servers_api = servers_api
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/ey-core/cli/helpers/server_sieve.rb', line 14

def options
  @options
end

#servers_apiObject (readonly)

Returns the value of attribute servers_api.



14
15
16
# File 'lib/ey-core/cli/helpers/server_sieve.rb', line 14

def servers_api
  @servers_api
end

Class Method Details

.filter(servers_api, options = {}) ⇒ Object



16
17
18
# File 'lib/ey-core/cli/helpers/server_sieve.rb', line 16

def self.filter(servers_api, options = {})
  new(servers_api, options).filtered
end

Instance Method Details

#filteredObject



25
26
27
28
29
30
31
# File 'lib/ey-core/cli/helpers/server_sieve.rb', line 25

def filtered
  return all_servers if requested?(:all)

  requested_roles.map {|role|
    role == :utilities ? utils_named(option(:utilities)) : send(role)
  }.flatten.uniq
end