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

Inherits:
Object
  • Object
show all
Includes:
Puppet::Util, Docs
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, RFC_3986_URI_REGEX

Constants included from SymbolicFileMode

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

Constants included from Puppet::Util::POSIX

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

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 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 SymbolicFileMode

#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?

Methods included from Puppet::Util::POSIX

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

Constructor Details

#initialize(name, docs, methods: nil) ⇒ ProviderFeature


33
34
35
36
37
# File 'lib/puppet/util/provider_features.rb', line 33

def initialize(name, docs, methods: nil)
  self.name = name.intern
  self.docs = docs
  @methods = methods
end

Instance Attribute Details

#docsObject

Returns the value of attribute docs


16
17
18
# File 'lib/puppet/util/provider_features.rb', line 16

def docs
  @docs
end

#methodsObject

Returns the value of attribute methods


16
17
18
# File 'lib/puppet/util/provider_features.rb', line 16

def methods
  @methods
end

#nameObject

Returns the value of attribute name


16
17
18
# File 'lib/puppet/util/provider_features.rb', line 16

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?.


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

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