Class: Coercible::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/project/configuration.rb

Overview

Configuration object for global and per coercer type settings

Class Method Summary collapse

Class Method Details

.build(keys) {|config| ... } ⇒ Configuration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a configuration instance

Parameters:

  • list (Array)

    of accessor keys

Yields:

  • (config)

Returns:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/project/configuration.rb', line 14

def self.build(keys, &block)
  config = new
  keys.each do |key|
    config.instance_eval do
      define_singleton_method("#{key}")  { instance_variable_get("@#{key}") }
      define_singleton_method("#{key}=") { |value| instance_variable_set("@#{key}", value) }
    end
  end
  yield(config) if block_given?
  config
end