Sha256: a9131d4d252eb7155535ba67b3de5f2f5a6cb86a8cb8deba3970f33900b7e370

Contents?: true

Size: 1.56 KB

Versions: 146

Compression:

Stored size: 1.56 KB

Contents

require 'puppet'
require 'puppet/type'
require 'puppet/transaction'

Puppet::Type.newtype(:component) do
  include Enumerable

  newparam(:name) do
    desc "The name of the component.  Generally optional."
    isnamevar
  end

  # Override how parameters are handled so that we support the extra
  # parameters that are used with defined resource types.
  def [](param)
    return super if self.class.valid_parameter?(param)
    @extra_parameters[param.to_sym]
  end

  # Override how parameters are handled so that we support the extra
  # parameters that are used with defined resource types.
  def []=(param, value)
    return super if self.class.valid_parameter?(param)
    @extra_parameters[param.to_sym] = value
  end

  # Initialize a new component
  def initialize(*args)
    @extra_parameters = {}
    super
  end

  # Component paths are special because they function as containers.
  def pathbuilder
    if reference.type == "Class"
      myname = reference.title
    else
      myname = reference.to_s
    end
    if p = self.parent
      return [p.pathbuilder, myname]
    else
      return [myname]
    end
  end

  def ref
    reference.to_s
  end

  # We want our title to just be the whole reference, rather than @title.
  def title
    ref
  end

  def title=(str)
    @reference = Puppet::Resource.new(str)
  end

  def refresh
    catalog.adjacent(self).each do |child|
      if child.respond_to?(:refresh)
        child.refresh
        child.log "triggering #{:refresh}"
      end
    end
  end

  def to_s
    reference.to_s
  end

  private

  attr_reader :reference
end

Version data entries

146 entries across 146 versions & 2 rubygems

Version Path
puppet-4.4.1-x64-mingw32 lib/puppet/type/component.rb
puppet-4.4.1-universal-darwin lib/puppet/type/component.rb
puppet-4.4.0 lib/puppet/type/component.rb
puppet-4.4.0-x86-mingw32 lib/puppet/type/component.rb
puppet-4.4.0-x64-mingw32 lib/puppet/type/component.rb
puppet-4.4.0-universal-darwin lib/puppet/type/component.rb
puppet-3.8.6 lib/puppet/type/component.rb
puppet-3.8.6-x86-mingw32 lib/puppet/type/component.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/type/component.rb
puppet-3.8.6-x64-mingw32 lib/puppet/type/component.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/type/component.rb
puppet-4.3.2 lib/puppet/type/component.rb
puppet-4.3.2-x86-mingw32 lib/puppet/type/component.rb
puppet-4.3.2-x64-mingw32 lib/puppet/type/component.rb
puppet-3.8.5 lib/puppet/type/component.rb
puppet-3.8.5-x86-mingw32 lib/puppet/type/component.rb
puppet-3.8.5-x64-mingw32 lib/puppet/type/component.rb
puppet-4.3.1 lib/puppet/type/component.rb
puppet-4.3.1-x86-mingw32 lib/puppet/type/component.rb
puppet-4.3.1-x64-mingw32 lib/puppet/type/component.rb