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.

Instance Method Summary collapse

Constructor Details

#initialize(block, options) ⇒ DynamicServerList

Returns a new instance of DynamicServerList.



45
46
47
48
49
50
# File 'lib/capistrano/role.rb', line 45

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

Instance Method Details

#reset!Object

Clear the cached value



62
63
64
65
# File 'lib/capistrano/role.rb', line 62

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

#to_aryObject

Convert to a list of ServerDefinitions



53
54
55
56
57
58
59
# File 'lib/capistrano/role.rb', line 53

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