Class: Puppet::Parser::Resource::Param

Inherits:
Object
  • Object
show all
Includes:
Util, Util::Errors
Defined in:
lib/puppet/parser/resource/param.rb

Overview

The parameters we stick in Resources.

Constant Summary

Constants included from Util

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

Constants included from Util::POSIX

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

Constants included from Util::SymbolicFileMode

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Methods included from 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 Util::POSIX

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

Methods included from Util::SymbolicFileMode

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

Constructor Details

#initialize(name: nil, value: nil, source: nil, line: nil, file: nil, add: nil) ⇒ Param

Returns a new instance of Param.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/parser/resource/param.rb', line 10

def initialize(name: nil, value: nil, source: nil, line: nil, file: nil, add: nil)
  @value = value
  @source = source
  @line = line
  @file = file
  @add = add

  unless name
    # This must happen after file and line are set to have them reported in the error
    self.fail(Puppet::ResourceError, "'name' is a required option for #{self.class}")
  end
  @name = name.intern
end

Instance Attribute Details

#addObject

Returns the value of attribute add.



8
9
10
# File 'lib/puppet/parser/resource/param.rb', line 8

def add
  @add
end

#fileObject

Returns the value of attribute file.



8
9
10
# File 'lib/puppet/parser/resource/param.rb', line 8

def file
  @file
end

#lineObject

Returns the value of attribute line.



8
9
10
# File 'lib/puppet/parser/resource/param.rb', line 8

def line
  @line
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/puppet/parser/resource/param.rb', line 8

def name
  @name
end

#sourceObject

Returns the value of attribute source.



8
9
10
# File 'lib/puppet/parser/resource/param.rb', line 8

def source
  @source
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/puppet/parser/resource/param.rb', line 8

def value
  @value
end

Class Method Details

.from_param(param, value) ⇒ Object



32
33
34
35
36
# File 'lib/puppet/parser/resource/param.rb', line 32

def self.from_param(param, value)
  new_param = param.dup
  new_param.value = value
  new_param
end

Instance Method Details

#line_to_iObject



24
25
26
# File 'lib/puppet/parser/resource/param.rb', line 24

def line_to_i
  line ? Integer(line) : nil
end

#to_sObject



28
29
30
# File 'lib/puppet/parser/resource/param.rb', line 28

def to_s
  "#{name} => #{value}"
end