Sha256: fab7840f38037c958eeff5109d17919735dd792c74438831505f2afe3329e552

Contents?: true

Size: 842 Bytes

Versions: 20

Compression:

Stored size: 842 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
    "#{name} => #{value}"
  end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/parser/resource/param.rb
puppet-8.10.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.10.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.10.0-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.9.0 lib/puppet/parser/resource/param.rb
puppet-8.9.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.9.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.9.0-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.8.1 lib/puppet/parser/resource/param.rb
puppet-8.8.1-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.8.1-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.8.1-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.7.0 lib/puppet/parser/resource/param.rb
puppet-8.7.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.7.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.7.0-universal-darwin lib/puppet/parser/resource/param.rb
puppet-8.6.0 lib/puppet/parser/resource/param.rb
puppet-8.6.0-x86-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.6.0-x64-mingw32 lib/puppet/parser/resource/param.rb
puppet-8.6.0-universal-darwin lib/puppet/parser/resource/param.rb