Parent

Included Modules

Files

Class/Module Index [+]

Quicksearch

Capistrano::Role

Public Class Methods

new(*list) click to toggle source
# File lib/capistrano/role.rb, line 5
def initialize(*list)
  @static_servers = []
  @dynamic_servers = []
  push(*list)
end

Protected Class Methods

wrap_list(*list) click to toggle source

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
wrap_server(item, options) click to toggle source

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

Public Instance Methods

<<(*list) click to toggle source
Alias for: push
clear() click to toggle source
# File lib/capistrano/role.rb, line 36
def clear
  @dynamic_servers.clear
  @static_servers.clear
end
each(&block) click to toggle source
# File lib/capistrano/role.rb, line 11
def each(&block)
  servers.each &block
end
empty?() click to toggle source
# File lib/capistrano/role.rb, line 32
def empty?
  servers.empty?
end
include?(server) click to toggle source
# File lib/capistrano/role.rb, line 41
def include?(server)
  servers.include?(server)
end
push(*list) click to toggle source
# 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
Also aliased as: <<
servers() click to toggle source
# File lib/capistrano/role.rb, line 27
def servers
  @static_servers + dynamic_servers
end
Also aliased as: to_ary
to_ary() click to toggle source
Alias for: servers

Protected Instance Methods

dynamic_servers() click to toggle source

Attribute reader for the cached results of executing the blocks in turn

# File lib/capistrano/role.rb, line 73
def dynamic_servers
  @dynamic_servers.inject([]) { |list, item| list.concat item }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.