Sha256: 7a195a17cc0b19a3109e2df2c5472c4cd7fc8ab400b5bc7664e712eaedfb5857

Contents?: true

Size: 1.8 KB

Versions: 88

Compression:

Stored size: 1.8 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

    catalog.alias(self, ref) if catalog and ! catalog.resource(ref)
  end

  # Component paths are special because they function as containers.
  def pathbuilder
    if reference.type == "Class"
      # 'main' is the top class, so we want to see '//' instead of
      # its name.
      if reference.title.to_s.downcase == "main"
        myname = ""
      else
        myname = reference.title
      end
    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

88 entries across 88 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/type/component.rb
puppet-parse-0.1.3 lib/vendor/puppet/type/component.rb
puppet-parse-0.1.2 lib/vendor/puppet/type/component.rb
puppet-parse-0.1.1 lib/vendor/puppet/type/component.rb
puppet-2.7.26 lib/puppet/type/component.rb
puppet-2.7.25 lib/puppet/type/component.rb
puppet-2.7.24 lib/puppet/type/component.rb
puppet-3.2.4 lib/puppet/type/component.rb
puppet-2.7.23 lib/puppet/type/component.rb
puppet-3.2.3 lib/puppet/type/component.rb
puppet-3.2.3.rc1 lib/puppet/type/component.rb
puppet-3.2.2 lib/puppet/type/component.rb
puppet-2.7.22 lib/puppet/type/component.rb
puppet-3.2.1 lib/puppet/type/component.rb
puppet-3.2.1.rc1 lib/puppet/type/component.rb
puppet-3.2.0.rc2 lib/puppet/type/component.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/type/component.rb
puppet-3.2.0.rc1 lib/puppet/type/component.rb
puppet-parse-0.1.0 lib/vendor/puppet/type/component.rb
puppet-parse-0.0.6 lib/vendor/puppet/type/component.rb