Class: ICFS::Web::Config Abstract
- Inherits:
-
Object
- Object
- ICFS::Web::Config
- Defined in:
- lib/icfs/web/config.rb
Overview
This class is abstract.
Configuration storage interface
Direct Known Subclasses
Constant Summary collapse
- ValConfig =
Valid config options
{ method: :hash, optional: { 'tz' => { method: :string, valid: /[+\-](0[0-9]|1[0-2]):[0-5][0-9]/.freeze, whitelist: true, } } }
Instance Attribute Summary collapse
-
#data ⇒ Object
The configuration values hash.
-
#defaults ⇒ Object
readonly
The configuration defaults.
Instance Method Summary collapse
-
#get(key) ⇒ Object
Get a value.
-
#initialize(defaults = {}) ⇒ Config
constructor
New instance.
-
#load(unam) ⇒ Boolean
Load a user configuration.
-
#save ⇒ Object
Save a user configuration.
-
#set(key, val) ⇒ Object
Set a value.
Constructor Details
#initialize(defaults = {}) ⇒ Config
New instance
41 42 43 44 45 |
# File 'lib/icfs/web/config.rb', line 41 def initialize(defaults={}) @data = {} @unam = nil @defaults = defaults end |
Instance Attribute Details
#data ⇒ Object
The configuration values hash
51 52 53 |
# File 'lib/icfs/web/config.rb', line 51 def data @data end |
#defaults ⇒ Object (readonly)
The configuration defaults
57 58 59 |
# File 'lib/icfs/web/config.rb', line 57 def defaults @defaults end |
Instance Method Details
#get(key) ⇒ Object
Get a value
65 66 67 |
# File 'lib/icfs/web/config.rb', line 65 def get(key) @data.key?(key) ? @data[key] : @defaults[key] end |
#load(unam) ⇒ Boolean
Load a user configuration
96 |
# File 'lib/icfs/web/config.rb', line 96 def load(unam); raise NotImplementedError; end |
#save ⇒ Object
Save a user configuration
102 |
# File 'lib/icfs/web/config.rb', line 102 def save; raise NotImplementedError; end |
#set(key, val) ⇒ Object
Set a value
76 77 78 |
# File 'lib/icfs/web/config.rb', line 76 def set(key, val) @data[key] = val end |