Reference documentation and code samples for the gapic-common module Gapic::Config.
Config is a simple DSL for creating Configuration classes.
Example
require "gapic/config" class SampleConfig extend Gapic::Config config_attr :name, nil, String, nil config_attr :active, true, true, false config_attr :count, nil, Numeric, nil config_attr :env, :production, String, Symbol def initialize parent_config = nil @parent_config = parent_config unless parent_config.nil? yield self if block_given? end end config = SampleConfig.new config.name #=> nil config.name = "thor" #=> "thor" config.name #=> "thor" config.name = :thor # ArgumentError
Methods
#config_attr
def config_attr(name, default, *valid_values, &validator)
Add configuration attribute methods to the configuratin class.
Parameters
- name (String, Symbol) — The name of the option
- default (Object, nil) — Initial value (nil is allowed)
- valid_values (Array) — A list of valid types
Raises
- (NameError)