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.
28 29 30 31 |
# 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 |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
22 23 24 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22 def commands @commands end |
#confines ⇒ Object (readonly)
Returns the value of attribute confines.
22 23 24 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22 def confines @confines end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
22 23 24 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22 def defaults @defaults end |
#features ⇒ Object (readonly)
Returns the value of attribute features.
22 23 24 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22 def features @features end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
22 23 24 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22 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.
71 72 73 74 75 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 71 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.
43 44 45 46 47 |
# 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(constraints) ⇒ void
This method returns an undefined value.
Adds a default to the provider.
61 62 63 64 65 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 61 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.
52 53 54 55 56 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 52 def add_feature(feature) return unless feature @features ||= [] @features << feature end |
#to_hash ⇒ Hash
Converts the code object to a hash representation.
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 79 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.
35 36 37 |
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 35 def type :puppet_provider end |