Sha256: 55c77d7cd1397fa7b4c1d000f488461352455f26b7a637cdb9d748b272f7f629

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 KB

Contents

require 'puppet/provider/confine_collection'

# 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.
#
module Puppet::Provider::Confiner
  # 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
  #
  # @example
  #   confine :operatingsystem => [:redhat, :fedora]
  #   confine :true { ... }
  #
  # @param hash [Hash<{Symbol => Object}>] hash of confines
  # @return [void]
  # @api public
  #
  def confine(hash)
    confine_collection.confine(hash)
  end

  # @return [Puppet::Provider::ConfineCollection] the collection of confines
  # @api private
  #
  def confine_collection
    @confine_collection ||= Puppet::Provider::ConfineCollection.new(self.to_s)
  end

  # Checks whether this implementation is suitable for the current platform (or returns a summary
  # of all confines if short == false).
  # @return [Boolean. Hash] Returns whether the confines are all valid (if short == true), or a hash of all confines
  #   if short == false. 
  # @api public
  #
  def suitable?(short = true)
    return(short ? confine_collection.valid? : confine_collection.summary)
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/provider/confiner.rb
puppet-3.1.1 lib/puppet/provider/confiner.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/provider/confiner.rb
puppet-3.1.0 lib/puppet/provider/confiner.rb
puppet-3.1.0.rc2 lib/puppet/provider/confiner.rb
puppet-3.1.0.rc1 lib/puppet/provider/confiner.rb