Class: Puppet::Util::ProviderFeatures::ProviderFeature

Inherits:
Object
  • Object
show all
Includes:
Puppet::Util, Docs, MethodHelper
Defined in:
lib/puppet/util/provider_features.rb

Overview

TODO:

Unclear what is api and what is private in this class

This class models provider features and handles checking whether the features are present.

Constant Summary

Constants included from Docs

Docs::HEADER_LEVELS

Constants included from Puppet::Util

AbsolutePathPosix, AbsolutePathWindows, DEFAULT_POSIX_MODE, DEFAULT_WINDOWS_MODE

Constants included from Puppet::Util::POSIX

Puppet::Util::POSIX::LOCALE_ENV_VARS, Puppet::Util::POSIX::USER_ENV_VARS

Constants included from SymbolicFileMode

SymbolicFileMode::SetGIDBit, SymbolicFileMode::SetUIDBit, SymbolicFileMode::StickyBit, SymbolicFileMode::SymbolicMode, SymbolicFileMode::SymbolicSpecialToBit

Instance Attribute Summary collapse

Attributes included from Docs

#doc, #nodoc

Instance Method Summary collapse

Methods included from Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Puppet::Util

absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask

Methods included from Puppet::Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from SymbolicFileMode

#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?

Constructor Details

#initialize(name, docs, hash) ⇒ ProviderFeature

Returns a new instance of ProviderFeature.



35
36
37
38
39
40
# File 'lib/puppet/util/provider_features.rb', line 35

def initialize(name, docs, hash)
  self.name = name.intern
  self.docs = docs
  hash = symbolize_options(hash)
  set_options(hash)
end

Instance Attribute Details

#docsObject

Returns the value of attribute docs.



18
19
20
# File 'lib/puppet/util/provider_features.rb', line 18

def docs
  @docs
end

#methodsObject

Returns the value of attribute methods.



18
19
20
# File 'lib/puppet/util/provider_features.rb', line 18

def methods
  @methods
end

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/puppet/util/provider_features.rb', line 18

def name
  @name
end

Instance Method Details

#available?(obj) ⇒ Boolean

Are all of the requirements met? Requirements are checked by checking if feature predicate methods have been generated - see #methods_available?.

Parameters:

  • obj (Object, Class)

    the object or class to check if requirements are met

Returns:

  • (Boolean)

    whether all requirements for this feature are met or not.



24
25
26
27
28
29
30
31
32
33
# File 'lib/puppet/util/provider_features.rb', line 24

def available?(obj)
  if self.methods
    return !!methods_available?(obj)
  else
    # In this case, the provider has to declare support for this
    # feature, and that's been checked before we ever get to the
    # method checks.
    return false
  end
end