Class: Capistrano::Conditional::Unit

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano-conditional/unit.rb

Overview

Stores the actual conditionals added by the user, including under what conditions the conditional should be applied (conditions) and what to do if that’s the case (block).

Created from ConditionalDeploy.register, the end user should never need to interact with it directly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts, block) ⇒ Unit

Returns a new instance of Unit.



12
13
14
15
16
17
18
19
20
# File 'lib/capistrano-conditional/unit.rb', line 12

def initialize(name, opts, block)
  @name = name
  @message = opts.delete(:msg)
  @block = block
  @conditions = {}
  opts.each do |k,v|
    @conditions[k] = v
  end
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



10
11
12
# File 'lib/capistrano-conditional/unit.rb', line 10

def block
  @block
end

#conditionsObject

Returns the value of attribute conditions.



10
11
12
# File 'lib/capistrano-conditional/unit.rb', line 10

def conditions
  @conditions
end

#messageObject

Returns the value of attribute message.



10
11
12
# File 'lib/capistrano-conditional/unit.rb', line 10

def message
  @message
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/capistrano-conditional/unit.rb', line 10

def name
  @name
end

Instance Method Details

#applies?(changed) ⇒ Boolean

Currently supported options: any_match (aliased to watchlist), none_match, if, unless

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/capistrano-conditional/unit.rb', line 23

def applies?(changed)
  @changed = changed
  any_match_applies? && none_match_applies? && if_applies? && unless_applies?
end