Class: PuppetStrings::Yard::CodeObjects::Provider

Inherits:
Base
  • Object
show all
Defined in:
lib/puppet-strings/yard/code_objects/provider.rb

Overview

Implements the Puppet provider code object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

new

Constructor Details

#initialize(type_name, name) ⇒ void

Initializes a Puppet provider code object.

Parameters:

  • type_name (String)

    The resource type name for the provider.

  • name (String)

    The name of the provider.s



30
31
32
33
# 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

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



24
25
26
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 24

def commands
  @commands
end

#confinesObject (readonly)

Returns the value of attribute confines.



24
25
26
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 24

def confines
  @confines
end

#defaultsObject (readonly)

Returns the value of attribute defaults.



24
25
26
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 24

def defaults
  @defaults
end

#featuresObject (readonly)

Returns the value of attribute features.



24
25
26
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 24

def features
  @features
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



24
25
26
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 24

def type_name
  @type_name
end

Instance Method Details

#add_command(key, value) ⇒ void

This method returns an undefined value.

Adds a command to the provider.

Parameters:

  • key (String)

    The command’s key.

  • value (String)

    The command’s value.



76
77
78
79
80
81
# 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) ⇒ void

This method returns an undefined value.

Adds a confine to the provider.

Parameters:

  • key (String)

    The confine’s key.

  • value (String)

    The confine’s value.



45
46
47
48
49
50
# 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) ⇒ void

This method returns an undefined value.

Adds a default to the provider.

Parameters:

  • constraints (Array)

    List of related key-pair values for the default.



65
66
67
68
69
70
# 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) ⇒ void

This method returns an undefined value.

Adds a feature to the provider.

Parameters:

  • feature (String)

    The feature to add to the provider.



55
56
57
58
59
60
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 55

def add_feature(feature)
  return unless feature

  @features ||= []
  @features << feature
end

#to_hashHash

Converts the code object to a hash representation.

Returns:

  • (Hash)

    Returns a hash representation of the code object.



85
86
87
88
89
90
91
92
93
94
95
96
97
# 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

#typeObject

Gets the type of the code object.

Returns:

  • Returns the type of the code object.



37
38
39
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 37

def type
  :puppet_provider
end