Class: Ferry::Configuration::Server
- Inherits:
-
SSHKit::Host
- Object
- SSHKit::Host
- Ferry::Configuration::Server
- Extended by:
- Forwardable
- Defined in:
- lib/ferry/configuration/server.rb
Defined Under Namespace
Classes: Properties
Class Method Summary collapse
Instance Method Summary collapse
- #add_role(role) ⇒ Object
- #add_roles(roles) ⇒ Object (also: #roles=)
- #has_role?(role) ⇒ Boolean
- #matches?(other) ⇒ Boolean
- #netssh_options ⇒ Object
- #primary ⇒ Object
- #properties ⇒ Object
- #roles_array ⇒ Object
- #select?(options) ⇒ Boolean
- #with(properties) ⇒ Object
Class Method Details
.[](host) ⇒ Object
8 9 10 |
# File 'lib/ferry/configuration/server.rb', line 8 def self.[](host) host.is_a?(Server) ? host : new(host) end |
Instance Method Details
#add_role(role) ⇒ Object
18 19 20 21 |
# File 'lib/ferry/configuration/server.rb', line 18 def add_role(role) roles.add role.to_sym self end |
#add_roles(roles) ⇒ Object Also known as: roles=
12 13 14 15 |
# File 'lib/ferry/configuration/server.rb', line 12 def add_roles(roles) Array(roles).each { |role| add_role(role) } self end |
#has_role?(role) ⇒ Boolean
23 24 25 |
# File 'lib/ferry/configuration/server.rb', line 23 def has_role?(role) roles.include? role.to_sym end |
#matches?(other) ⇒ Boolean
64 65 66 |
# File 'lib/ferry/configuration/server.rb', line 64 def matches?(other) hostname == other.hostname end |
#netssh_options ⇒ Object
56 57 58 |
# File 'lib/ferry/configuration/server.rb', line 56 def @netssh_options ||= super.merge( fetch(:ssh_options) || {} ) end |
#primary ⇒ Object
43 44 45 |
# File 'lib/ferry/configuration/server.rb', line 43 def primary self if fetch(:primary) end |
#properties ⇒ Object
52 53 54 |
# File 'lib/ferry/configuration/server.rb', line 52 def properties @properties ||= Properties.new end |
#roles_array ⇒ Object
60 61 62 |
# File 'lib/ferry/configuration/server.rb', line 60 def roles_array roles.to_a end |
#select?(options) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ferry/configuration/server.rb', line 27 def select?() .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 self.fetch(k) == v end return false unless result end return true end |
#with(properties) ⇒ Object
47 48 49 50 |
# File 'lib/ferry/configuration/server.rb', line 47 def with(properties) properties.each { |key, value| add_property(key, value) } self end |