Class: CFG::DictWrapper
- Inherits:
-
Hash
- Object
- Hash
- CFG::DictWrapper
- Defined in:
- lib/CFG/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #as_dict ⇒ Object
- #base_get ⇒ Object
-
#initialize(config) ⇒ DictWrapper
constructor
A new instance of DictWrapper.
Constructor Details
#initialize(config) ⇒ DictWrapper
Returns a new instance of DictWrapper.
1776 1777 1778 |
# File 'lib/CFG/config.rb', line 1776 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
1772 1773 1774 |
# File 'lib/CFG/config.rb', line 1772 def config @config end |
Instance Method Details
#[](key) ⇒ Object
1795 1796 1797 1798 1799 |
# File 'lib/CFG/config.rb', line 1795 def [](key) raise ConfigError, "Not found in configuration: #{key}" unless include? key @config.evaluated base_get(key) end |
#as_dict ⇒ Object
1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 |
# File 'lib/CFG/config.rb', line 1780 def as_dict result = {} each do |k, v| rv = @config.evaluated v if rv.is_a?(DictWrapper) || rv.is_a?(Config) rv = rv.as_dict elsif rv.is_a? ListWrapper rv = rv.as_list end result[k] = rv end result end |
#base_get ⇒ Object
1774 |
# File 'lib/CFG/config.rb', line 1774 alias base_get [] |