Module: Puppet::Confiner
- Included in:
- Network::Format, Provider
- Defined in:
- lib/puppet/confiner.rb
Overview
The Confiner module contains methods for managing a Provider’s confinement (suitability under given conditions). The intent is to include this module in an object where confinement management is wanted. It lazily adds an instance variable ‘@confine_collection` to the object where it is included.
Instance Method Summary collapse
-
#confine(hash) ⇒ void
Confines a provider to be suitable only under the given conditions.
-
#confine_collection ⇒ Puppet::ConfineCollection
private
The collection of confines.
-
#suitable?(short = true) ⇒ Boolean. Hash
Checks whether this implementation is suitable for the current platform (or returns a summary of all confines if short == false).
Instance Method Details
#confine(hash) ⇒ void
This method returns an undefined value.
Confines a provider to be suitable only under the given conditions. The hash describes a confine using mapping from symbols to values or predicate code.
-
fact_name => value of fact (or array of facts)
-
‘:exists` => the path to an existing file
-
‘:true` => a predicate code block returning true
-
‘:false` => a predicate code block returning false
-
‘:feature` => name of system feature that must be present
-
‘:any` => an array of expressions that will be ORed together
27 28 29 |
# File 'lib/puppet/confiner.rb', line 27 def confine(hash) confine_collection.confine(hash) end |
#confine_collection ⇒ Puppet::ConfineCollection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the collection of confines.
34 35 36 |
# File 'lib/puppet/confiner.rb', line 34 def confine_collection @confine_collection ||= Puppet::ConfineCollection.new(self.to_s) end |
#suitable?(short = true) ⇒ Boolean. Hash
Checks whether this implementation is suitable for the current platform (or returns a summary of all confines if short == false).
44 45 46 |
# File 'lib/puppet/confiner.rb', line 44 def suitable?(short = true) return(short ? confine_collection.valid? : confine_collection.summary) end |