Class: R10K::Feature::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/feature/collection.rb

Overview

Store all features and indicate if they’re available.

Instance Method Summary collapse

Constructor Details

#initializeCollection

Returns a new instance of Collection.



5
6
7
# File 'lib/r10k/feature/collection.rb', line 5

def initialize
  @features = {}
end

Instance Method Details

#add(name, opts = {}, &block) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)

    The feature to add

  • opts (Hash) (defaults to: {})

    Additional options for the feature, see R10K::Feature

  • block (Proc)

    An optional block to detect if this feature is present



13
14
15
# File 'lib/r10k/feature/collection.rb', line 13

def add(name, opts = {}, &block)
  @features[name] = R10K::Feature.new(name, opts, &block)
end

#available?(name) ⇒ true, false

Returns Does a feature by this name exist and is it available?.

Returns:

  • (true, false)

    Does a feature by this name exist and is it available?



18
19
20
21
22
# File 'lib/r10k/feature/collection.rb', line 18

def available?(name)
  if @features.key?(name)
    @features[name].available?
  end
end