Class: CfDeployer::Driver::DryRun
- Inherits:
-
Object
- Object
- CfDeployer::Driver::DryRun
- Defined in:
- lib/cf_deployer/driver/dry_run.rb
Constant Summary collapse
- @@enabled =
false
Class Method Summary collapse
- .disable ⇒ Object
- .disable_for(&block) ⇒ Object
- .enable ⇒ Object
- .enable_for(&block) ⇒ Object
- .enabled? ⇒ Boolean
- .guard(description) ⇒ Object
- .run_with_value(value, &block) ⇒ Object
Class Method Details
.disable ⇒ Object
36 37 38 39 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 36 def self.disable CfDeployer::Log.info "Disabling Dry-Run Mode" @@enabled = false end |
.disable_for(&block) ⇒ Object
27 28 29 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 27 def self.disable_for &block run_with_value(false, &block) end |
.enable ⇒ Object
31 32 33 34 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 31 def self.enable CfDeployer::Log.info "Enabling Dry-Run Mode" @@enabled = true end |
.enable_for(&block) ⇒ Object
23 24 25 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 23 def self.enable_for &block run_with_value(true, &block) end |
.enabled? ⇒ Boolean
7 8 9 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 7 def self.enabled? @@enabled end |
.guard(description) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 41 def self.guard description if @@enabled CfDeployer::Log.info "<Dry Run Enabled> #{description}" else yield end end |
.run_with_value(value, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cf_deployer/driver/dry_run.rb', line 11 def self.run_with_value value, &block previous_value = @@enabled @@enabled = value begin block.call rescue => e raise e ensure @@enabled = previous_value end end |