Method: Aruba::BasicConfiguration.option_reader

Defined in:
lib/aruba/basic_configuration.rb

.option_reader(name, type:, default: nil) ⇒ Object

Define an option reader

Parameters:

  • name (Symbol)

    The name of the reader

  • [Class, (Hash)

    a customizable set of options

  • [Object] (Hash)

    a customizable set of options

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
# File 'lib/aruba/basic_configuration.rb', line 28

def option_reader(name, type:, default: nil)
  raise ArgumentError, "Either use block or default value" if block_given? && default

  add_option(name, block_given? ? yield(InConfigWrapper.new(known_options)) : default)

  Contract None => type
  define_method(name) { find_option(name).value }
end