Module: Serega::Config::ConfigInstanceMethods

Extended by:
Forwardable
Included in:
Serega::Config
Defined in:
lib/serega/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optsHash (readonly)

Returns Current config data.

Returns:

  • (Hash)

    Current config data



14
15
16
# File 'lib/serega/config.rb', line 14

def opts
  @opts
end

Instance Method Details

#[](name) ⇒ Object

Get config option, delegates to opts#[]

Parameters:

  • name (Symbol)

    option name

Returns:

  • (Object)


42
# File 'lib/serega/config.rb', line 42

def_delegators :opts, :[], :[]=, :fetch, :keys, :has_key?

#[]=(name) ⇒ Object

Set config option, delegates to opts#[]=

Parameters:

  • name (Symbol)

    option name

Returns:

  • (Object)


42
# File 'lib/serega/config.rb', line 42

def_delegators :opts, :[], :[]=, :fetch, :keys, :has_key?

#fetch(name) ⇒ Object

Fetch config option, delegates to opts#fetch

Parameters:

  • name (Symbol)

    option name

Returns:

  • (Object)


42
# File 'lib/serega/config.rb', line 42

def_delegators :opts, :[], :[]=, :fetch, :keys, :has_key?

#initialize(opts = {}) ⇒ Object

Initializes new config instance and deeply duplicates all provided options to remove possibility of accidental overwriting of parent/nested configs.

Parameters:

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

    Initial config options



22
23
24
# File 'lib/serega/config.rb', line 22

def initialize(opts = {})
  @opts = Utils::EnumDeepDup.call(opts)
end