module ConfigMapper

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

Constants

VERSION

Public Class Methods

configure_with(data, target) click to toggle source

Set attributes of a target object based on configuration data.

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.

@param data configuration data @param [Object, Hash] target the object to configure

@return [Hash] exceptions encountered

# File lib/config_mapper.rb, line 25
def configure_with(data, target)
  mapper_for(target).configure_with(data)
end
Also aliased as: set
mapper_for(target) click to toggle source
# File lib/config_mapper.rb, line 31
def mapper_for(target)
  if target.respond_to?(:[]) && target.respond_to?(:each)
    CollectionMapper.new(target)
  else
    ObjectMapper.new(target)
  end
end
set(data, target)
Alias for: configure_with