Sha256: 9f9b78fbc1a7027ab6ac0db6e1cb2b465c6ece6a18f352ae3fdc3a32671a5e3c

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

module Coercible

  # Configuration object for global and per coercer type settings
  #
  class Configuration

    # Build a configuration instance
    #
    # @param [Array] list of accessor keys
    #
    # @return [Configuration]
    #
    # @api private
    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

  end # class Configuration

end # module Coercible

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion_coercible-0.2.0.2 lib/project/configuration.rb
motion_coercible-0.2.0.1 lib/project/configuration.rb