Class: PuppetX::Rustup::Provider::Collection
- Inherits:
-
Object
- Object
- PuppetX::Rustup::Provider::Collection
- Includes:
- Enumerable
- Defined in:
- lib/puppet_x/rustup/provider/collection.rb
Overview
A collection value in a provider
Direct Known Subclasses
Instance Attribute Summary collapse
-
#values ⇒ Object
Either the subresources set from the resource, or if nothing is set, the subresources on the system.
Class Method Summary collapse
-
.plural_name(plural_name = nil) ⇒ Object
Use this to set the plural name for the class.
Instance Method Summary collapse
-
#each ⇒ Object
Implement Enumerable.
-
#initialize(provider) ⇒ Collection
constructor
A new instance of Collection.
-
#load ⇒ Object
Get values actually present on the system.
-
#plural_name ⇒ Object
Get the plural_name from the class.
-
#system ⇒ Object
Get subresources installed on the system (memoized).
Constructor Details
#initialize(provider) ⇒ Collection
Returns a new instance of Collection.
16 17 18 19 20 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 16 def initialize(provider) @provider = provider @system = :unset @values = nil end |
Instance Attribute Details
#values ⇒ Object
Either the subresources set from the resource, or if nothing is set, the subresources on the system.
44 45 46 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 44 def values @values || system end |
Class Method Details
.plural_name(plural_name = nil) ⇒ Object
Use this to set the plural name for the class
12 13 14 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 12 def self.plural_name(plural_name = nil) @plural_name ||= plural_name || name.split('::').last end |
Instance Method Details
#each ⇒ Object
Implement Enumerable
33 34 35 36 37 38 39 40 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 33 def each if block_given? values.each { |value| yield value } self else enum_for(__callee__) end end |
#load ⇒ Object
Get values actually present on the system.
23 24 25 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 23 def load raise 'Unimplemented.' end |
#plural_name ⇒ Object
Get the plural_name from the class
28 29 30 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 28 def plural_name self.class.plural_name end |
#system ⇒ Object
Get subresources installed on the system (memoized).
Just memoizes load.
51 52 53 54 55 56 |
# File 'lib/puppet_x/rustup/provider/collection.rb', line 51 def system if @system == :unset load end @system end |