Class: Puppet::Util::RunMode

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/run_mode.rb

Direct Known Subclasses

UnixRunMode, WindowsRunMode

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ RunMode

Returns a new instance of RunMode.



6
7
8
# File 'lib/puppet/util/run_mode.rb', line 6

def initialize(name)
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/puppet/util/run_mode.rb', line 10

def name
  @name
end

Class Method Details

.[](name) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/puppet/util/run_mode.rb', line 12

def self.[](name)
  @run_modes ||= {}
  if Puppet.features.microsoft_windows?
    @run_modes[name] ||= WindowsRunMode.new(name)
  else
    @run_modes[name] ||= UnixRunMode.new(name)
  end
end

Instance Method Details

#agent?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/puppet/util/run_mode.rb', line 25

def agent?
  name == :agent
end

#log_dirObject



37
38
39
# File 'lib/puppet/util/run_mode.rb', line 37

def log_dir
  RunMode[name].log_dir
end

#master?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/puppet/util/run_mode.rb', line 21

def master?
  name == :master
end

#run_dirObject



33
34
35
# File 'lib/puppet/util/run_mode.rb', line 33

def run_dir
  RunMode[name].run_dir
end

#user?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/puppet/util/run_mode.rb', line 29

def user?
  name == :user
end