Turns a list, or something resembling a list, into a properly-formatted ServerDefinition list. Keep an eye on this one -- it's entirely too magical for its own good. In particular, if ServerDefinition ever inherits from Array, this will break.
# File lib/capistrano/role.rb, line 87 def self.wrap_list (*list) options = list.last.is_a?(Hash) ? list.pop : {} if list.length == 1 if list.first.nil? return [] elsif list.first.is_a?(Array) list = list.first end end options.merge! list.pop if list.last.is_a?(Hash) list.map do |item| self.wrap_server item, options end end
Wraps a string in a ServerDefinition, if it isn't already. This and wrap_list should probably go in ServerDefinition in some form.
# File lib/capistrano/role.rb, line 79 def self.wrap_server (item, options) item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options) end
# File lib/capistrano/role.rb, line 36 def clear @dynamic_servers.clear @static_servers.clear end
# File lib/capistrano/role.rb, line 11 def each(&block) servers.each &block end
# File lib/capistrano/role.rb, line 32 def empty? servers.empty? end
# File lib/capistrano/role.rb, line 41 def include?(server) servers.include?(server) end
# File lib/capistrano/role.rb, line 15 def push(*list) options = list.last.is_a?(Hash) ? list.pop : {} list.each do |item| if item.respond_to?(:call) @dynamic_servers << DynamicServerList.new(item, options) else @static_servers << self.class.wrap_server(item, options) end end end
# File lib/capistrano/role.rb, line 27 def servers @static_servers + dynamic_servers end
Generated with the Darkfish Rdoc Generator 2.