Sha256: 44bbcbec6ee24c4136e43b0e016db320467ab8a393972f86d3c0f8281dd547d6

Contents?: true

Size: 858 Bytes

Versions: 20

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true
# The parameters we stick in Resources.
class Puppet::Parser::Resource::Param
  include Puppet::Util
  include Puppet::Util::Errors

  attr_accessor :name, :value, :source, :add, :file, :line

  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

  def line_to_i
    line ? Integer(line) : nil
  end

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/parser/resource/param.rb
puppet-8.3.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.3.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.3.0-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.3.1 lib/puppet/parser/resource/param.rb
puppet-8.3.1-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.3.1-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.3.1-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.2.0 lib/puppet/parser/resource/param.rb
puppet-8.2.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.2.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.2.0-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.1.0 lib/puppet/parser/resource/param.rb
puppet-8.1.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.1.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.1.0-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.0.1 lib/puppet/parser/resource/param.rb
puppet-8.0.1-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.0.1-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.0.1-universal-darwin lib/puppet/parser/resource/param.rb