Class: Capistrano::Conditional::Unit
- Inherits:
-
Object
- Object
- Capistrano::Conditional::Unit
- 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
-
#block ⇒ Object
Returns the value of attribute block.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#message ⇒ Object
Returns the value of attribute message.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#applies?(changed) ⇒ Boolean
Currently supported options: any_match (aliased to watchlist), none_match, if, unless.
-
#initialize(name, opts, block) ⇒ Unit
constructor
A new instance of Unit.
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
#block ⇒ Object
Returns the value of attribute block.
10 11 12 |
# File 'lib/capistrano-conditional/unit.rb', line 10 def block @block end |
#conditions ⇒ Object
Returns the value of attribute conditions.
10 11 12 |
# File 'lib/capistrano-conditional/unit.rb', line 10 def conditions @conditions end |
#message ⇒ Object
Returns the value of attribute message.
10 11 12 |
# File 'lib/capistrano-conditional/unit.rb', line 10 def @message end |
#name ⇒ Object
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
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 |