class PuppetStrings::Yard::CodeObjects::Provider

Implements the Puppet provider code object.

Attributes

commands[R]
confines[R]
defaults[R]
features[R]
type_name[R]

Public Class Methods

new(type_name, name) click to toggle source

Initializes a Puppet provider code object. @param [String] type_name The resource type name for the provider. @param [String] name The name of the provider.s @return [void]

# File lib/puppet-strings/yard/code_objects/provider.rb, line 30
def initialize(type_name, name)
  @type_name = type_name
  super(PuppetStrings::Yard::CodeObjects::Providers.instance(type_name), name)
end

Public Instance Methods

add_command(key, value) click to toggle source

Adds a command to the provider. @param [String] key The command’s key. @param [String] value The command’s value. @return [void]

# File lib/puppet-strings/yard/code_objects/provider.rb, line 76
def add_command(key, value)
  return unless key && value

  @commands ||= {}
  @commands[key] = value
end
add_confine(key, value) click to toggle source

Adds a confine to the provider. @param [String] key The confine’s key. @param [String] value The confine’s value. @return [void]

# File lib/puppet-strings/yard/code_objects/provider.rb, line 45
def add_confine(key, value)
  return unless key && value

  @confines ||= {}
  @confines[key] = value
end
add_default(constraints) click to toggle source

Adds a default to the provider. @param [Array] constraints List of related key-pair values for the default. @return [void]

# File lib/puppet-strings/yard/code_objects/provider.rb, line 65
def add_default(constraints)
  return unless constraints

  @defaults ||= []
  @defaults << constraints
end
add_feature(feature) click to toggle source

Adds a feature to the provider. @param [String] feature The feature to add to the provider. @return [void]

# File lib/puppet-strings/yard/code_objects/provider.rb, line 55
def add_feature(feature)
  return unless feature

  @features ||= []
  @features << feature
end
to_hash() click to toggle source

Converts the code object to a hash representation. @return [Hash] Returns a hash representation of the code object.

# File lib/puppet-strings/yard/code_objects/provider.rb, line 85
def to_hash
  hash = {}
  hash[:name] = name
  hash[:type_name] = type_name
  hash[:file] = file
  hash[:line] = line
  hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
  hash[:confines] = confines if confines && !confines.empty?
  hash[:features] = features if features && !features.empty?
  hash[:defaults] = defaults if defaults && !defaults.empty?
  hash[:commands] = commands if commands && !commands.empty?
  hash
end
type() click to toggle source

Gets the type of the code object. @return Returns the type of the code object.

# File lib/puppet-strings/yard/code_objects/provider.rb, line 37
def type
  :puppet_provider
end