class Puppet::ResourceApi::TypeDefinition

RSAPI Resource Type

Public Class Methods

new(definition) click to toggle source
# File lib/puppet/resource_api/type_definition.rb, line 8
def initialize(definition)
  super(definition, :attributes)
end

Public Instance Methods

ensurable?() click to toggle source
# File lib/puppet/resource_api/type_definition.rb, line 12
def ensurable?
  attributes.key?(:ensure)
end
feature?(feature) click to toggle source

rubocop complains when this is named has_feature?

# File lib/puppet/resource_api/type_definition.rb, line 17
def feature?(feature)
  (definition[:features] && definition[:features].include?(feature))
end
title_patterns() click to toggle source
# File lib/puppet/resource_api/type_definition.rb, line 21
def title_patterns
  definition[:title_patterns] ||= []
end
validate_schema(definition, attr_key) click to toggle source
# File lib/puppet/resource_api/type_definition.rb, line 25
def validate_schema(definition, attr_key)
  super(definition, attr_key)
  [:title, :provider, :alias, :audit, :before, :consume, :export, :loglevel, :noop, :notify, :require, :schedule, :stage, :subscribe, :tag].each do |name|
    raise Puppet::DevError, 'must not define an attribute called `%{name}`' % { name: name.inspect } if definition[attr_key].key? name
  end
  if definition.key?(:title_patterns) && !definition[:title_patterns].is_a?(Array)
    raise Puppet::DevError, '`:title_patterns` must be an array, not `%{other_type}`' % { other_type: definition[:title_patterns].class }
  end

  Puppet::ResourceApi::DataTypeHandling.validate_ensure(definition)

  definition[:features] ||= []
  supported_features = %w[supports_noop canonicalize remote_resource simple_get_filter].freeze
  unknown_features = definition[:features] - supported_features
  Puppet.warning("Unknown feature detected: #{unknown_features.inspect}") unless unknown_features.empty?
end