Class: Capistrano::Role

### Home Classes Methods

### In Files

- lib/capistrano/role.rb

### Parent

Object

### Namespace

- CLASS Capistrano::Role::DynamicServerList

### Methods

- ::new
- ::wrap_list
- ::wrap_server
- #<<
- #clear
- #dynamic_servers
- #each
- #empty?
- #include?
- #push
- #servers
- #to_ary

### Included Modules

- Enumerable

### Files

- help.txt

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::CLI
- Capistrano::CLI::Execute
- Capistrano::CLI::Execute::ClassMethods
- Capistrano::CLI::Help
- Capistrano::CLI::Options
- Capistrano::CLI::Options::ClassMethods
- Capistrano::CLI::UI
- Capistrano::CLI::UI::ClassMethods
- Capistrano::Callback
- Capistrano::Command
- Capistrano::Command::Tree
- Capistrano::Command::Tree::Branch
- Capistrano::Command::Tree::ConditionBranch
- Capistrano::Command::Tree::ConditionBranch::Evaluator
- Capistrano::Command::Tree::ElseBranch
- Capistrano::Configuration
- Capistrano::Configuration::Actions
- Capistrano::Configuration::Actions::FileTransfer
- Capistrano::Configuration::Actions::Inspect
- Capistrano::Configuration::Actions::Invocation
- Capistrano::Configuration::Actions::Invocation::ClassMethods
- Capistrano::Configuration::AliasTask
- Capistrano::Configuration::Callbacks
- Capistrano::Configuration::Connections
- Capistrano::Configuration::Execution
- Capistrano::Configuration::Loading
- Capistrano::Configuration::Loading::ClassMethods
- Capistrano::Configuration::LogFormatters
- Capistrano::Configuration::Namespaces
- Capistrano::Configuration::Namespaces::Namespace
- Capistrano::Configuration::Roles
- Capistrano::Configuration::Servers
- Capistrano::Configuration::Variables
- Capistrano::Deploy
- Capistrano::Deploy::Dependencies
- Capistrano::Deploy::LocalDependency
- Capistrano::Deploy::RemoteDependency
- Capistrano::Deploy::SCM
- Capistrano::Deploy::SCM::Accurev
- Capistrano::Deploy::SCM::Accurev::InternalRevision
- Capistrano::Deploy::SCM::Base
- Capistrano::Deploy::SCM::Base::LocalProxy
- Capistrano::Deploy::SCM::Bzr
- Capistrano::Deploy::SCM::Cvs
- Capistrano::Deploy::SCM::Darcs
- Capistrano::Deploy::SCM::Git
- Capistrano::Deploy::SCM::Mercurial
- Capistrano::Deploy::SCM::None
- Capistrano::Deploy::SCM::Perforce
- Capistrano::Deploy::SCM::Subversion
- Capistrano::Deploy::Strategy
- Capistrano::Deploy::Strategy::Base
- Capistrano::Deploy::Strategy::Checkout
- Capistrano::Deploy::Strategy::Copy
- Capistrano::Deploy::Strategy::Export
- Capistrano::Deploy::Strategy::Remote
- Capistrano::Deploy::Strategy::RemoteCache
- Capistrano::Deploy::Strategy::UnsharedRemoteCache
- Capistrano::ProcCallback
- Capistrano::Processable
- Capistrano::Processable::SessionAssociation
- Capistrano::RemoteError
- Capistrano::Role
- Capistrano::Role::DynamicServerList
- Capistrano::SSH
- Capistrano::ServerDefinition
- Capistrano::Shell
- Capistrano::TaskCallback
- Capistrano::TaskDefinition
- Capistrano::Transfer
- Capistrano::Transfer::SFTPTransferWrapper
- Capistrano::Version
- Kernel
- Object
- String

No matching classes.

# 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.