Class: SecretConfig::Config

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/secret_config/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, registry) ⇒ Config

Returns a new instance of Config.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
# File 'lib/secret_config/config.rb', line 7

def initialize(path, registry)
  raise(ArgumentError, "path cannot be nil") if path.nil?

  @path     = path
  @registry = registry
end

Instance Method Details

#[](sub_path) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
# File 'lib/secret_config/config.rb', line 20

def [](sub_path)
  raise(ArgumentError, "sub_path cannot be nil") if sub_path.nil?

  registry[join_path(sub_path)]
end

#[]=(sub_path, value) ⇒ Object

Raises:

  • (ArgumentError)


26
27
28
29
30
# File 'lib/secret_config/config.rb', line 26

def []=(sub_path, value)
  raise(ArgumentError, "sub_path cannot be nil") if sub_path.nil?

  registry[join_path(sub_path)] = value
end

#delete(sub_path) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
# File 'lib/secret_config/config.rb', line 44

def delete(sub_path)
  raise(ArgumentError, "sub_path cannot be nil") if sub_path.nil?

  registry.delete(join_path(sub_path))
end

#fetch(sub_path, **options) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/secret_config/config.rb', line 14

def fetch(sub_path, **options)
  raise(ArgumentError, "sub_path cannot be nil") if sub_path.nil?

  registry.fetch(join_path(sub_path), **options)
end

#key?(sub_path) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


32
33
34
35
36
# File 'lib/secret_config/config.rb', line 32

def key?(sub_path)
  raise(ArgumentError, "sub_path cannot be nil") if sub_path.nil?

  registry.key?(join_path(sub_path))
end

#set(sub_path, value) ⇒ Object

Raises:

  • (ArgumentError)


38
39
40
41
42
# File 'lib/secret_config/config.rb', line 38

def set(sub_path, value)
  raise(ArgumentError, "sub_path cannot be nil") if sub_path.nil?

  registry.set(join_path(sub_path), value)
end