Class Capistrano::Role
In: lib/capistrano/role.rb
lib/capistrano/role.rb
Parent: Object

Methods

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

Included Modules

Enumerable Enumerable

Classes and Modules

Class Capistrano::Role::DynamicServerList

Public Class methods

[Source]

   # File lib/capistrano/role.rb, line 5
5:     def initialize(*list)
6:       @static_servers = []
7:       @dynamic_servers = []
8:       push(*list)
9:     end

[Source]

   # File lib/capistrano/role.rb, line 5
5:     def initialize(*list)
6:       @static_servers = []
7:       @dynamic_servers = []
8:       push(*list)
9:     end

Protected Class methods

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.

[Source]

     # File lib/capistrano/role.rb, line 87
 87:     def self.wrap_list (*list)
 88:       options = list.last.is_a?(Hash) ? list.pop : {}
 89:       if list.length == 1
 90:         if list.first.nil?
 91:           return []
 92:         elsif list.first.is_a?(Array)
 93:           list = list.first
 94:         end
 95:       end
 96:       options.merge! list.pop if list.last.is_a?(Hash)
 97:       list.map do |item|
 98:         self.wrap_server item, options
 99:       end
100:     end

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.

[Source]

     # File lib/capistrano/role.rb, line 87
 87:     def self.wrap_list (*list)
 88:       options = list.last.is_a?(Hash) ? list.pop : {}
 89:       if list.length == 1
 90:         if list.first.nil?
 91:           return []
 92:         elsif list.first.is_a?(Array)
 93:           list = list.first
 94:         end
 95:       end
 96:       options.merge! list.pop if list.last.is_a?(Hash)
 97:       list.map do |item|
 98:         self.wrap_server item, options
 99:       end
100:     end

Wraps a string in a ServerDefinition, if it isn‘t already. This and wrap_list should probably go in ServerDefinition in some form.

[Source]

    # File lib/capistrano/role.rb, line 79
79:     def self.wrap_server (item, options)
80:       item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options)
81:     end

Wraps a string in a ServerDefinition, if it isn‘t already. This and wrap_list should probably go in ServerDefinition in some form.

[Source]

    # File lib/capistrano/role.rb, line 79
79:     def self.wrap_server (item, options)
80:       item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options)
81:     end

Public Instance methods

<<(*list)

Alias for push

<<(*list)

Alias for push

[Source]

    # File lib/capistrano/role.rb, line 36
36:     def clear
37:       @dynamic_servers.clear
38:       @static_servers.clear
39:     end

[Source]

    # File lib/capistrano/role.rb, line 36
36:     def clear
37:       @dynamic_servers.clear
38:       @static_servers.clear
39:     end

[Source]

    # File lib/capistrano/role.rb, line 11
11:     def each(&block)
12:       servers.each &block
13:     end

[Source]

    # File lib/capistrano/role.rb, line 11
11:     def each(&block)
12:       servers.each &block
13:     end

[Source]

    # File lib/capistrano/role.rb, line 32
32:     def empty?
33:       servers.empty?
34:     end

[Source]

    # File lib/capistrano/role.rb, line 32
32:     def empty?
33:       servers.empty?
34:     end

[Source]

    # File lib/capistrano/role.rb, line 41
41:     def include?(server)
42:       servers.include?(server)
43:     end

[Source]

    # File lib/capistrano/role.rb, line 41
41:     def include?(server)
42:       servers.include?(server)
43:     end

[Source]

    # File lib/capistrano/role.rb, line 15
15:     def push(*list)
16:       options = list.last.is_a?(Hash) ? list.pop : {}
17:       list.each do |item|
18:         if item.respond_to?(:call)
19:           @dynamic_servers << DynamicServerList.new(item, options)
20:         else
21:           @static_servers << self.class.wrap_server(item, options)
22:         end
23:       end
24:     end

[Source]

    # File lib/capistrano/role.rb, line 15
15:     def push(*list)
16:       options = list.last.is_a?(Hash) ? list.pop : {}
17:       list.each do |item|
18:         if item.respond_to?(:call)
19:           @dynamic_servers << DynamicServerList.new(item, options)
20:         else
21:           @static_servers << self.class.wrap_server(item, options)
22:         end
23:       end
24:     end

[Source]

    # File lib/capistrano/role.rb, line 27
27:     def servers
28:       @static_servers + dynamic_servers
29:     end

[Source]

    # File lib/capistrano/role.rb, line 27
27:     def servers
28:       @static_servers + dynamic_servers
29:     end
to_ary()

Alias for servers

to_ary()

Alias for servers

Protected Instance methods

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

[Source]

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

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

[Source]

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

[Validate]