Class: ChefCLI::Policyfile::LockApplier
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::LockApplier
- Defined in:
- lib/chef-cli/policyfile/lock_applier.rb
Overview
A class that can apply constraints from a lock to a compiler
Instance Attribute Summary collapse
-
#policyfile_compiler ⇒ Object
readonly
Returns the value of attribute policyfile_compiler.
-
#policyfile_lock ⇒ Object
readonly
Returns the value of attribute policyfile_lock.
-
#unlocked_policies ⇒ Object
readonly
Returns the value of attribute unlocked_policies.
Instance Method Summary collapse
-
#apply! ⇒ Object
Apply locks described in policyfile_lock allowing for the deviations asked for.
-
#initialize(policyfile_lock, policyfile_compiler) ⇒ LockApplier
constructor
Initialize a LockApplier.
-
#with_unlocked_policies(policies) ⇒ Object
Unlocks included policies.
Constructor Details
#initialize(policyfile_lock, policyfile_compiler) ⇒ LockApplier
Initialize a LockApplier. By default, all locked data this class knows about will be applied to the compiler. Currently, it applies locks only for included policies.
33 34 35 36 37 |
# File 'lib/chef-cli/policyfile/lock_applier.rb', line 33 def initialize(policyfile_lock, policyfile_compiler) @policyfile_lock = policyfile_lock @policyfile_compiler = policyfile_compiler @unlocked_policies = [] end |
Instance Attribute Details
#policyfile_compiler ⇒ Object (readonly)
Returns the value of attribute policyfile_compiler.
25 26 27 |
# File 'lib/chef-cli/policyfile/lock_applier.rb', line 25 def policyfile_compiler @policyfile_compiler end |
#policyfile_lock ⇒ Object (readonly)
Returns the value of attribute policyfile_lock.
24 25 26 |
# File 'lib/chef-cli/policyfile/lock_applier.rb', line 24 def policyfile_lock @policyfile_lock end |
#unlocked_policies ⇒ Object (readonly)
Returns the value of attribute unlocked_policies.
23 24 25 |
# File 'lib/chef-cli/policyfile/lock_applier.rb', line 23 def unlocked_policies @unlocked_policies end |
Instance Method Details
#apply! ⇒ Object
No changes are applied until apply! is invoked
Apply locks described in policyfile_lock allowing for the deviations asked for.
58 59 60 |
# File 'lib/chef-cli/policyfile/lock_applier.rb', line 58 def apply! prepare_constraints_for_policies end |
#with_unlocked_policies(policies) ⇒ Object
Unlocks included policies
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/chef-cli/policyfile/lock_applier.rb', line 43 def with_unlocked_policies(policies) if policies == :all || unlocked_policies == :all @unlocked_policies = :all else policies.each do |policy| @unlocked_policies << policy end end self end |