Class: Coercible::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/coercible/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
25
26
27
28
29
# File 'lib/coercible/configuration.rb', line 14

def self.build(keys, &block)
  config = new
  keys.each do |key|
    config.instance_eval <<-RUBY
      def #{key}
        @#{key}
      end

      def #{key}=(value)
        @#{key} = value
      end
    RUBY
  end
  yield(config) if block_given?
  config
end