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.
Constant Summary collapse
- VALID_CONDITIONS =
[:any_match, :none_match, :if, :unless, :watchlist]
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
- #default? ⇒ Boolean
-
#initialize(name, opts, block) ⇒ Unit
constructor
A new instance of Unit.
Constructor Details
#initialize(name, opts, block) ⇒ Unit
Returns a new instance of Unit.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/capistrano-conditional/unit.rb', line 14 def initialize(name, opts, block) @name = name = opts.delete(:msg) @block = block @conditions = {} = {} opts.each do |k,v| if VALID_CONDITIONS.include?(k) @conditions[k] = v else [k] = v end end end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
12 13 14 |
# File 'lib/capistrano-conditional/unit.rb', line 12 def block @block end |
#conditions ⇒ Object
Returns the value of attribute conditions.
12 13 14 |
# File 'lib/capistrano-conditional/unit.rb', line 12 def conditions @conditions end |
#message ⇒ Object
Returns the value of attribute message.
12 13 14 |
# File 'lib/capistrano-conditional/unit.rb', line 12 def end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/capistrano-conditional/unit.rb', line 12 def name @name end |
Instance Method Details
#applies?(changed) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/capistrano-conditional/unit.rb', line 30 def applies?(changed) @changed = changed return default? if ConditionalDeploy.in_default_mode? any_match_applies? && none_match_applies? && if_applies? && unless_applies? end |
#default? ⇒ Boolean
37 38 39 |
# File 'lib/capistrano-conditional/unit.rb', line 37 def default? !![:default] end |