Module: ConfigMapper

Defined in:
lib/config_mapper.rb,
lib/config_mapper/version.rb,
lib/config_mapper/error_proxy.rb,
lib/config_mapper/attribute_sink.rb,
lib/config_mapper/object_as_hash.rb

Overview

Supports marshalling of plain-old data (e.g. loaded from YAML files) onto strongly-typed objects.

Defined Under Namespace

Classes: AttributeSink, ErrorProxy, ObjectAsHash

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.set(data, target) ⇒ Hash

Attempt to set attributes on a target object.

For simple, scalar values, set the attribute by calling the named writer-method on the target object.

For Hash values, set attributes of the named sub-component.

Returns:

  • (Hash)

    exceptions encountered



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

def self.set(data, target)
  mapper = AttributeSink.new(target)
  mapper.set_attributes(data)
  mapper.errors
end