Class: PuppetStrings::Yard::CodeObjects::Provider
- Inherits:
-
Base
- Object
- YARD::CodeObjects::NamespaceObject
- Base
- PuppetStrings::Yard::CodeObjects::Provider
- Defined in:
- lib/puppet-strings/yard/code_objects/provider.rb
Overview
Implements the Puppet provider code object.
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#confines ⇒ Object
readonly
Returns the value of attribute confines.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Instance Method Summary collapse
-
#add_command(key, value) ⇒ void
Adds a command to the provider.
-
#add_confine(key, value) ⇒ void
Adds a confine to the provider.
-
#add_default(constraints) ⇒ void
Adds a default to the provider.
-
#add_feature(feature) ⇒ void
Adds a feature to the provider.
-
#initialize(type_name, name) ⇒ void
constructor
Initializes a Puppet provider code object.
-
#to_hash ⇒ Hash
Converts the code object to a hash representation.
-
#type ⇒ Object
Gets the type of the code object.
Methods inherited from Base
Constructor Details
#initialize(type_name, name) ⇒ void
Initializes a Puppet provider code object.
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
#commands ⇒ Object (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 |
#confines ⇒ Object (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 |
#defaults ⇒ Object (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 |
#features ⇒ Object (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_name ⇒ Object (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.
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.
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.
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.
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_hash ⇒ Hash
Converts the code object to a hash representation.
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 |
#type ⇒ Object
Gets 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 |