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.



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

Returns:

  • (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