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?   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 83
83:     def self.wrap_list (*list)
84:       options = list.last.is_a?(Hash) ? list.pop : {}
85:       if list.length == 1
86:         if list.first.nil?
87:           return []
88:         elsif list.first.is_a?(Array)
89:           list = list.first
90:         end
91:       end
92:       options.merge! list.pop if list.last.is_a?(Hash)
93:       list.map do |item|
94:         self.wrap_server item, options
95:       end
96:     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 83
83:     def self.wrap_list (*list)
84:       options = list.last.is_a?(Hash) ? list.pop : {}
85:       if list.length == 1
86:         if list.first.nil?
87:           return []
88:         elsif list.first.is_a?(Array)
89:           list = list.first
90:         end
91:       end
92:       options.merge! list.pop if list.last.is_a?(Hash)
93:       list.map do |item|
94:         self.wrap_server item, options
95:       end
96:     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 75
75:     def self.wrap_server (item, options)
76:       item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options)
77:     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 75
75:     def self.wrap_server (item, options)
76:       item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options)
77:     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 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 69
69:     def dynamic_servers
70:       @dynamic_servers.inject([]) { |list, item| list.concat item }
71:     end

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

[Source]

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

[Validate]