Class: EacRubyUtils::Configs

Inherits:
Object
  • Object
show all
Includes:
SimpleCache
Defined in:
lib/eac_ruby_utils/configs.rb,
lib/eac_ruby_utils/configs/base.rb,
lib/eac_ruby_utils/configs/file.rb

Defined Under Namespace

Classes: Base, File

Constant Summary

Constants included from SimpleCache

SimpleCache::UNCACHED_METHOD_PATTERN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SimpleCache

#method_missing, #reset_cache, #respond_to_missing?

Constructor Details

#initialize(configs_key, options = {}) ⇒ Configs

Valid options: [:storage_path]


17
18
19
20
21
# File 'lib/eac_ruby_utils/configs.rb', line 17

def initialize(configs_key, options = {})
  @configs_key = configs_key
  @options = options.to_sym_keys_hash.freeze
  load
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EacRubyUtils::SimpleCache

Instance Attribute Details

#configs_keyObject (readonly)

Returns the value of attribute configs_key


14
15
16
# File 'lib/eac_ruby_utils/configs.rb', line 14

def configs_key
  @configs_key
end

#optionsObject (readonly)

Returns the value of attribute options


14
15
16
# File 'lib/eac_ruby_utils/configs.rb', line 14

def options
  @options
end

Instance Method Details

#[](entry_key) ⇒ Object


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

def [](entry_key)
  read_entry(entry_key)
end

#[]=(entry_key, entry_value) ⇒ Object


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

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

#read_entry(entry_key) ⇒ Object


41
42
43
# File 'lib/eac_ruby_utils/configs.rb', line 41

def read_entry(entry_key)
  file.read(entry_key)
end

#write_entry(entry_key, entry_value) ⇒ Object


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

def write_entry(entry_key, entry_value)
  file.write(entry_key, entry_value)
end