Class: ConfigMapper::Mapper

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

Overview

Something that accepts configuration.

Direct Known Subclasses

CollectionMapper, ObjectMapper

Instance Method Summary collapse

Instance Method Details

#configure_with(data) ⇒ Hash

Map configuration data onto the target.

Returns:

  • (Hash)

    exceptions encountered



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/config_mapper/mapper.rb', line 13

def configure_with(data)
  errors = {}
  if data.respond_to?(:each_pair)
    data.each_pair do |key, value|
      configure_attribute(key, value, errors)
    end
  else
    data.each_with_index do |value, index|
      configure_attribute(index, value, errors)
    end
  end
  errors
end