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

ALNUM, ALPHA, AbsolutePathPosix, AbsolutePathWindows, DEFAULT_POSIX_MODE, DEFAULT_WINDOWS_MODE, ESCAPED, HEX, HttpProxy, Puppet::Util::PUPPET_STACK_INSERTION_FRAME, RESERVED, RFC_3986_URI_REGEX, UNRESERVED, UNSAFE

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 Puppet::Util

absolute_path?, benchmark, chuser, clear_environment, create_erb, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, format_backtrace_array, format_puppetstack_frame, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, resolve_stackframe, rfc2396_escape, safe_posix_fork, set_env, skip_external_facts, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, uri_unescape, which, withenv, withumask

Methods included from Puppet::Util::POSIX

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

Methods included from SymbolicFileMode

#display_mode, #normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?

Constructor Details

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

Returns a new instance of ProviderFeature.



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

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.



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