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-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.4.1 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.4.0 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.3.2 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.3.1 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.3.0 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.2.1 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-retrospec-1.2.0 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-4.6.1-x86-mingw32 lib/puppet/type/component.rb
puppet-4.6.1 lib/puppet/type/component.rb
puppet-4.6.1-x64-mingw32 lib/puppet/type/component.rb
puppet-4.6.1-universal-darwin lib/puppet/type/component.rb
puppet-retrospec-1.1.0 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-4.5.3 lib/puppet/type/component.rb
puppet-4.5.3-x86-mingw32 lib/puppet/type/component.rb
puppet-4.5.3-x64-mingw32 lib/puppet/type/component.rb
puppet-4.5.3-universal-darwin lib/puppet/type/component.rb
puppet-retrospec-1.0.0 vendor/gems/puppet-4.5.2/lib/puppet/type/component.rb
puppet-4.5.2 lib/puppet/type/component.rb
puppet-4.5.2-x86-mingw32 lib/puppet/type/component.rb