Class: PRC::SectionConfig
- Inherits:
-
BaseConfig
- Object
- BaseConfig
- PRC::SectionConfig
- Includes:
- PRC::SectionConfigRubySpec::Public
- Defined in:
- lib/prc_section_config.rb
Overview
SectionConfig class layer based on BaseConfig.
It supports a data_options :section for #[], #[]=, etc…
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BaseConfig
#data, #filename, #latest_version, #version
Instance Method Summary collapse
-
#[](*keys) ⇒ Object
Get the value of a specific key under a section.
-
#del(*keys) ⇒ Object
remove the key under a section.
-
#exist?(*keys) ⇒ Boolean
Check key existence under a section.
Methods included from PRC::SectionConfigRubySpec::Public
Methods inherited from BaseConfig
#data_options, #erase, #initialize, #latest_version?, #load, #rh_key_to_symbol, #rh_key_to_symbol?, #save, #to_s, #where?
Methods included from BaseConfigRubySpec::Private
Methods included from BaseConfigRubySpec::Public
Constructor Details
This class inherits a constructor from PRC::BaseConfig
Instance Method Details
#[](*keys) ⇒ Object
Get the value of a specific key under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys
: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
44 45 46 47 48 |
# File 'lib/prc_section_config.rb', line 44 def [](*keys) return nil if keys.length == 0 return p_get(:default, *keys) if @data_options[:section].nil? p_get(@data_options[:section], *keys) end |
#del(*keys) ⇒ Object
remove the key under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys
: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
76 77 78 79 80 |
# File 'lib/prc_section_config.rb', line 76 def del(*keys) return nil if keys.length == 0 return p_del(:default, *keys) if @data_options[:section].nil? p_del(@data_options[:section], *keys) end |
#exist?(*keys) ⇒ Boolean
Check key existence under a section. You have to call #data_options(:section => ‘MySection’)
-
Args :
-
keys
: keys to get values from a section set by data_options. If section is not set, it will use :default
-
-
Returns :
-
key value.
-
-
Raises : Nothing
60 61 62 63 64 |
# File 'lib/prc_section_config.rb', line 60 def exist?(*keys) return nil if keys.length == 0 return p_exist?(:default, *keys) if @data_options[:section].nil? p_exist?(@data_options[:section], *keys) end |