Class: EacRubyUtils::Configs::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/configs/base.rb

Direct Known Subclasses

File

Instance Method Summary collapse

Instance Method Details

#[](entry_key) ⇒ Object



20
21
22
# File 'lib/eac_ruby_utils/configs/base.rb', line 20

def [](entry_key)
  read(entry_key)
end

#[]=(entry_key, entry_value) ⇒ Object



16
17
18
# File 'lib/eac_ruby_utils/configs/base.rb', line 16

def []=(entry_key, entry_value)
  write(entry_key, entry_value)
end

#clearObject



24
25
26
# File 'lib/eac_ruby_utils/configs/base.rb', line 24

def clear
  replace({})
end

#read(entry_key) ⇒ Object



28
29
30
31
32
# File 'lib/eac_ruby_utils/configs/base.rb', line 28

def read(entry_key)
  return nil unless data.key?(entry_key)

  data.fetch(entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
end

#replace(new_data) ⇒ Object



34
35
36
# File 'lib/eac_ruby_utils/configs/base.rb', line 34

def replace(new_data)
  self.data = ::EacRubyUtils::PathsHash.new(new_data)
end

#write(entry_key, entry_value) ⇒ Object



38
39
40
# File 'lib/eac_ruby_utils/configs/base.rb', line 38

def write(entry_key, entry_value)
  data[entry_key] = entry_value
end