Class: Qa::LDF::Configuration

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/qa/ldf/configuration.rb

Overview

A singleton configuration class.

This behaves much like a hash, but guarantees that only one configuration exists and accepts a block sytax for configuration.

Examples:

configuring with a configuration hash

Qa::LDF::Configuration.instance
  .configure!(endpoint: 'http://example.org/ldf/')

configuring with block syntax

Qa::LDF::Configuration.instance.configure! do |config|
  config[:endpoint] = 'http://example.org/ldf/'
end

See Also:

Instance Method Summary collapse

Instance Method Details

#[]Object

Delegates to the underlying options



31
# File 'lib/qa/ldf/configuration.rb', line 31

def_delegator :@options, :'[]', :'[]'

#[]=Object

Delegates to the underlying options



32
# File 'lib/qa/ldf/configuration.rb', line 32

def_delegator :@options, :'[]=', :'[]='

#any?Object

Delegates to the underlying options



33
# File 'lib/qa/ldf/configuration.rb', line 33

def_delegator :@options, :any?, :any?

#configure!(**opts) {|config| ... } ⇒ Object

Parameters:

  • opts (Hash)

    @option endpoint [String]

Yields:

  • yields self to block

Yield Parameters:



52
53
54
55
56
# File 'lib/qa/ldf/configuration.rb', line 52

def configure!(**opts)
  @options = opts
  yield self if block_given?
  self
end

#eachObject

Delegates to the underlying options



34
# File 'lib/qa/ldf/configuration.rb', line 34

def_delegator :@options, :each, :each

#fetchObject

Delegates to the underlying options



35
# File 'lib/qa/ldf/configuration.rb', line 35

def_delegator :@options, :fetch, :fetch

#reset!Object

Empties all configuration options



62
63
64
# File 'lib/qa/ldf/configuration.rb', line 62

def reset!
  @options = {}
end

#to_aObject

Delegates to the underlying options



36
# File 'lib/qa/ldf/configuration.rb', line 36

def_delegator :@options, :to_a, :to_a

#to_hObject

Delegates to the underlying options



37
# File 'lib/qa/ldf/configuration.rb', line 37

def_delegator :@options, :to_h, :to_h