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.


49
50
51
52
53
54
# File 'lib/capistrano/role.rb', line 49

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

Instance Method Details

#reset!Object

Clear the cached value


66
67
68
69
# File 'lib/capistrano/role.rb', line 66

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

#to_aryObject

Convert to a list of ServerDefinitions


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

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