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.

API:

  • public

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?, activerecord_version, benchmark, binread, chuser, classproxy, deterministic_rand, execfail, execpipe, execute, exit_on_fail, logmethods, memory, path_to_uri, pretty_backtrace, proxy, replace_file, safe_posix_fork, symbolizehash, thinmark, 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.

API:

  • public



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

API:

  • public



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

def docs
  @docs
end

#methodsObject

API:

  • public



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

def methods
  @methods
end

#nameObject

API:

  • public



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:

  • the object or class to check if requirements are met

Returns:

  • whether all requirements for this feature are met or not.

API:

  • public



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