Class: ConfigMapper::CollectionMapper
- Defined in:
- lib/config_mapper/collection_mapper.rb
Overview
Configuration proxy for a collection (e.g. Hash, Array, ConfigDict)
Instance Method Summary collapse
- #can_set?(_key) ⇒ Boolean
- #get(key) ⇒ Object
-
#initialize(hash) ⇒ CollectionMapper
constructor
A new instance of CollectionMapper.
- #path(key) ⇒ Object
- #set(key, value) ⇒ Object
Methods inherited from Mapper
Constructor Details
#initialize(hash) ⇒ CollectionMapper
Returns a new instance of CollectionMapper.
11 12 13 |
# File 'lib/config_mapper/collection_mapper.rb', line 11 def initialize(hash) @hash = hash end |
Instance Method Details
#can_set?(_key) ⇒ Boolean
27 28 29 |
# File 'lib/config_mapper/collection_mapper.rb', line 27 def can_set?(_key) @hash.respond_to?("[]=") end |
#get(key) ⇒ Object
19 20 21 |
# File 'lib/config_mapper/collection_mapper.rb', line 19 def get(key) @hash[key] end |
#path(key) ⇒ Object
15 16 17 |
# File 'lib/config_mapper/collection_mapper.rb', line 15 def path(key) "[#{key.inspect}]" end |
#set(key, value) ⇒ Object
23 24 25 |
# File 'lib/config_mapper/collection_mapper.rb', line 23 def set(key, value) @hash[key] = value end |