Class: Tabry::Models::ConfigStringHash
- Inherits:
-
Object
- Object
- Tabry::Models::ConfigStringHash
- Includes:
- Enumerable
- Defined in:
- lib/tabry/models/config_string_hash.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#_raw ⇒ Object
readonly
Returns the value of attribute _raw.
-
#_root ⇒ Object
readonly
Returns the value of attribute _root.
-
#to_h ⇒ Object
readonly
Returns the value of attribute to_h.
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(raw:, root:, klass:) ⇒ ConfigStringHash
constructor
A new instance of ConfigStringHash.
- #keys ⇒ Object
Constructor Details
#initialize(raw:, root:, klass:) ⇒ ConfigStringHash
Returns a new instance of ConfigStringHash.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tabry/models/config_string_hash.rb', line 12 def initialize(raw:, root:, klass:) @_raw = raw @_root = root raw ||= {} unless raw.is_a?(Hash) raise ConfigError, "#{self.class.name} must be a Hash. Got #{raw.class}" end unless raw.keys.all? { |k| k.is_a?(String) } raise ConfigError, "#{self.class.name} keys must all be string keys." end @to_h = raw.transform_values { |a| klass.new(raw: a, root: root) } end |
Instance Attribute Details
#_raw ⇒ Object (readonly)
Returns the value of attribute _raw.
8 9 10 |
# File 'lib/tabry/models/config_string_hash.rb', line 8 def _raw @_raw end |
#_root ⇒ Object (readonly)
Returns the value of attribute _root.
8 9 10 |
# File 'lib/tabry/models/config_string_hash.rb', line 8 def _root @_root end |
#to_h ⇒ Object (readonly)
Returns the value of attribute to_h.
8 9 10 |
# File 'lib/tabry/models/config_string_hash.rb', line 8 def to_h @to_h end |
Instance Method Details
#[](*args) ⇒ Object
27 28 29 |
# File 'lib/tabry/models/config_string_hash.rb', line 27 def [](*args) to_h.[](*args) end |
#each ⇒ Object
31 32 33 |
# File 'lib/tabry/models/config_string_hash.rb', line 31 def each(...) to_h.each(...) end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/tabry/models/config_string_hash.rb', line 35 def empty? to_h.empty? end |
#keys ⇒ Object
39 40 41 |
# File 'lib/tabry/models/config_string_hash.rb', line 39 def keys to_h.keys end |