Class: ConfigMapper::CollectionMapper

Inherits:
Mapper
  • Object
show all
Defined in:
lib/config_mapper/collection_mapper.rb

Overview

Configuration proxy for a collection (e.g. Hash, Array, ConfigDict)

Instance Method Summary collapse

Methods inherited from Mapper

#configure_with

Constructor Details

#initialize(hash) ⇒ CollectionMapper

Returns a new instance of CollectionMapper.



9
10
11
# File 'lib/config_mapper/collection_mapper.rb', line 9

def initialize(hash)
  @hash = hash
end

Instance Method Details

#can_set?(key) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/config_mapper/collection_mapper.rb', line 25

def can_set?(key)
  @hash.respond_to?("[]=")
end

#get(key) ⇒ Object



17
18
19
# File 'lib/config_mapper/collection_mapper.rb', line 17

def get(key)
  @hash[key]
end

#path(key) ⇒ Object



13
14
15
# File 'lib/config_mapper/collection_mapper.rb', line 13

def path(key)
  "[#{key.inspect}]"
end

#set(key, value) ⇒ Object



21
22
23
# File 'lib/config_mapper/collection_mapper.rb', line 21

def set(key, value)
  @hash[key] = value
end