Class: Capistrano::Role
- Inherits:
-
Object
- Object
- Capistrano::Role
- Includes:
- Enumerable
- Defined in:
- lib/capistrano/role.rb
Defined Under Namespace
Classes: DynamicServerList
Instance Method Summary collapse
-
#clear ⇒ Object
Clears everything.
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(*list) ⇒ Role
constructor
A new instance of Role.
- #push(*list) ⇒ Object (also: #<<)
-
#reset! ⇒ Object
Resets the cache, so that proc values may be recalculated.
- #servers ⇒ Object (also: #to_ary)
Constructor Details
#initialize(*list) ⇒ Role
Returns a new instance of Role.
6 7 8 9 10 |
# File 'lib/capistrano/role.rb', line 6 def initialize(*list) @static_servers = [] @dynamic_servers = [] push(*list) end |
Instance Method Details
#clear ⇒ Object
Clears everything. I still thing this should be ‘clear!’, but that’s not the way Array does it.
47 48 49 50 |
# File 'lib/capistrano/role.rb', line 47 def clear @dynamic_servers.clear @static_servers.clear end |
#each(&block) ⇒ Object
12 13 14 |
# File 'lib/capistrano/role.rb', line 12 def each(&block) servers.each &block end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/capistrano/role.rb', line 33 def empty? servers.empty? end |
#push(*list) ⇒ Object Also known as: <<
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/capistrano/role.rb', line 16 def push(*list) = list.last.is_a?(Hash) ? list.pop : {} list.each do |item| if item.respond_to?(:call) @dynamic_servers << DynamicServerList.new(item, ) else @static_servers << self.class.wrap_server(item, ) end end end |
#reset! ⇒ Object
Resets the cache, so that proc values may be recalculated. There should be a command in Configuration::Roles to do this, but I haven’t needed it yet, and I’m not sure yet what to call that command. Suggestions?
41 42 43 |
# File 'lib/capistrano/role.rb', line 41 def reset! @dynamic_servers.each { |item| item.reset! } end |
#servers ⇒ Object Also known as: to_ary
28 29 30 |
# File 'lib/capistrano/role.rb', line 28 def servers @static_servers + dynamic_servers end |