Class: Flo::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/flo/config.rb

Overview

Instantiates and stores providers for use in command definitions

Defined Under Namespace

Classes: LazyCreds

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



32
33
34
# File 'lib/flo/config.rb', line 32

def initialize
  @providers = {}
end

Instance Attribute Details

#cred_storeObject



48
49
50
# File 'lib/flo/config.rb', line 48

def cred_store
  @cred_store ||= Flo::CredStore::YamlStore.new
end

#providersHash (readonly)

Hash of provider instances

Returns:

  • (Hash)

    the current value of providers



15
16
17
# File 'lib/flo/config.rb', line 15

def providers
  @providers
end

Instance Method Details

#credsLazyCred

Returns an object that responds to [], but instead of returning a value, returns a lambda that can be evaluated later in the context of the credentials for the provider

Returns:

  • (LazyCred)


55
56
57
# File 'lib/flo/config.rb', line 55

def creds
  LazyCreds.new
end

#provider(provider_sym, options = {}) { ... } ⇒ Object

Instantiate a provider and add it to the #providers collection accepts a block

Parameters:

  • provider_sym (Symbol)
  • options (Hash) (defaults to: {})

    Options to be passed to provider initialization

Yields:

  • Yields the block to the provider initializer, in case the provider



42
43
44
45
46
# File 'lib/flo/config.rb', line 42

def provider(provider_sym, options={}, &blk)
  provider = provider_class(provider_sym).new(options, &blk)
  provider.cred_store = cred_store.credentials_for(provider_sym)
  @providers[provider_sym] = provider
end