Class: Settei::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/settei/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base


26
27
28
29
30
31
32
# File 'lib/settei/base.rb', line 26

def initialize(config)
  if !config.is_a? Hash
    raise ArgumentError.new('config is not a hash')
  end

  self.config = config
end

Instance Method Details

#dig(key, ...) ⇒ Object

See Also:

  • Hash#dig

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#dig_and_wrap(*args) ⇒ Object

Same as #dig, but will wrap return value as a Settei::Base if it is a hash.


35
36
37
38
39
40
41
42
# File 'lib/settei/base.rb', line 35

def dig_and_wrap(*args)
  result = dig(*args)
  if result.is_a?(Hash)
    self.class.new(result)
  else
    result
  end
end

#fetch(key[, default]) ⇒ Object

See Also:

  • Hash#fetch

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#has_key?(key) ⇒ Object

See Also:

  • Hash#has_key?

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#include?(key) ⇒ Object

See Also:

  • Hash#include?

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#key?(key) ⇒ Object

See Also:

  • Hash#key?

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#member?(key) ⇒ Object

See Also:

  • Hash#member?

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#merge(*args) ⇒ Object

See Also:

  • Hash#merge

23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#to_hObject


23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h

#to_hashObject


23
# File 'lib/settei/base.rb', line 23

def_delegators :@config, :dig, :merge!, :fetch, :has_key?, :include?, :key?, :member?, :to_hash, :to_h