Class: SmartAttr::ConfigHash
- Inherits:
-
Object
- Object
- SmartAttr::ConfigHash
- Defined in:
- lib/smart_attr/config_hash.rb
Instance Attribute Summary collapse
-
#config_values_map ⇒ Object
readonly
Returns the value of attribute config_values_map.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(*args) ⇒ ConfigHash
constructor
A new instance of ConfigHash.
- #item(value) ⇒ Object
- #keys ⇒ Object
Constructor Details
#initialize(*args) ⇒ ConfigHash
Returns a new instance of ConfigHash.
6 7 8 9 10 11 12 13 14 |
# File 'lib/smart_attr/config_hash.rb', line 6 def initialize(*args) @config_hash = args. @config_values_map = {} @config_hash.each do |_key, _config| @config_values_map[_config[:value]] = _config.merge(key: _key) end end |
Instance Attribute Details
#config_values_map ⇒ Object (readonly)
Returns the value of attribute config_values_map.
4 5 6 |
# File 'lib/smart_attr/config_hash.rb', line 4 def config_values_map @config_values_map end |
Instance Method Details
#[](key) ⇒ Object
24 25 26 |
# File 'lib/smart_attr/config_hash.rb', line 24 def [](key) @config_hash[key] end |
#item(value) ⇒ Object
16 17 18 |
# File 'lib/smart_attr/config_hash.rb', line 16 def item(value) @config_values_map[value] end |
#keys ⇒ Object
20 21 22 |
# File 'lib/smart_attr/config_hash.rb', line 20 def keys @config_hash.keys end |