Class: Puppet::Settings::FileSetting::Service Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/settings/file_setting.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A “service” user or group that picks up values from settings when the referenced user or group is safe to use (it exists or will be created), and uses the given fallback value when not safe.

Instance Method Summary collapse

Constructor Details

#initialize(name, fallback, settings, available_method) ⇒ Service

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Service.

Parameters:

  • name (Symbol)

    the name of the setting to use as the service value

  • fallback (String, nil)

    the value to use when the service value cannot be used

  • settings (Puppet::Settings)

    the puppet settings object

  • available_method (Symbol)

    the name of the method to call on settings to determine if the value in settings is available on the system



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

def initialize(name, fallback, settings, available_method)
  @settings = settings
  @available_method = available_method
  @name = name
  @fallback = fallback
end

Instance Method Details

#valueObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
# File 'lib/puppet/settings/file_setting.rb', line 42

def value
  if safe_to_use_settings_value?
    @settings[@name]
  else
    @fallback
  end
end