Class: Capistrano::Role::DynamicServerList

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/role.rb

Overview

This is the combination of a block, a hash of options, and a cached value. It is protected because it is an implementation detail – the original implementation was two lists (blocks and cached results of calling them).

Instance Method Summary collapse

Constructor Details

#initialize(block, options) ⇒ DynamicServerList

Returns a new instance of DynamicServerList.



59
60
61
62
63
64
# File 'lib/capistrano/role.rb', line 59

def initialize (block, options)
  @block = block
  @options = options
  @cached = []
  @is_cached = false
end

Instance Method Details

#reset!Object

Clear the cached value



76
77
78
79
# File 'lib/capistrano/role.rb', line 76

def reset!
  @cached.clear
  @is_cached = false
end

#to_aryObject

Convert to a list of ServerDefinitions



67
68
69
70
71
72
73
# File 'lib/capistrano/role.rb', line 67

def to_ary
  unless @is_cached
    @cached = Role::wrap_list(@block.call(@options), @options)
    @is_cached = true
  end
  @cached
end