class Capistrano::Configuration::Server

Public Class Methods

[](host) click to toggle source
# File lib/capistrano/configuration/server.rb, line 8
def self.[](host)
  host.is_a?(Server) ? host : new(host)
end

Public Instance Methods

add_role(role) click to toggle source
# File lib/capistrano/configuration/server.rb, line 18
def add_role(role)
  roles.add role.to_sym
  self
end
add_roles(roles) click to toggle source
# File lib/capistrano/configuration/server.rb, line 12
def add_roles(roles)
  Array(roles).each { |role| add_role(role) }
  self
end
Also aliased as: roles=
has_role?(role) click to toggle source
# File lib/capistrano/configuration/server.rb, line 23
def has_role?(role)
  roles.include? role.to_sym
end
matches?(other) click to toggle source
# File lib/capistrano/configuration/server.rb, line 66
def matches?(other)
  # This matching logic must stay in sync with `Servers#add_host`.
  hostname == other.hostname && port == other.port
end
netssh_options() click to toggle source
Calls superclass method
# File lib/capistrano/configuration/server.rb, line 58
def netssh_options
  @netssh_options ||= super.merge(fetch(:ssh_options) || {})
end
primary() click to toggle source
# File lib/capistrano/configuration/server.rb, line 45
def primary
  self if fetch(:primary)
end
properties() click to toggle source
# File lib/capistrano/configuration/server.rb, line 54
def properties
  @properties ||= Properties.new
end
roles=(roles)
Alias for: add_roles
roles_array() click to toggle source
# File lib/capistrano/configuration/server.rb, line 62
def roles_array
  roles.to_a
end
select?(options) click to toggle source
# File lib/capistrano/configuration/server.rb, line 27
def select?(options)
  options.each do |k, v|
    callable = v.respond_to?(:call) ? v : ->(server) { server.fetch(v) }
    result = \
      case k
      when :filter, :select
        callable.call(self)
      when :exclude
        !callable.call(self)
      else
        fetch(k) == v
      end
    return false unless result
  end

  true
end
with(properties) click to toggle source
# File lib/capistrano/configuration/server.rb, line 49
def with(properties)
  properties.each { |key, value| add_property(key, value) }
  self
end

Private Instance Methods

add_property(key, value) click to toggle source
# File lib/capistrano/configuration/server.rb, line 73
def add_property(key, value)
  if respond_to?("#{key}=")
    send("#{key}=", value)
  else
    set(key, value)
  end
end