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 28
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 72
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 43
def add_confine(key, value)
  return unless key && value
  @confines ||= {}
  @confines[key] = value
end
add_default(key, value) click to toggle source

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

# File lib/puppet-strings/yard/code_objects/provider.rb, line 62
def add_default(key, value)
  return unless key && value
  @defaults ||= {}
  @defaults[key] = value
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 52
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 80
def to_hash
  hash = {}
  hash[:name] = name
  hash[:type_name] = type_name
  hash[:file] = file
  hash[:line] = line
  hash[:docstring] = PuppetStrings::Json.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 35
def type
  :puppet_provider
end