Module: Translatomatic::Config::Options

Extended by:
Util
Defined in:
lib/translatomatic/config/options.rb

Overview

A collection of all translatomatic options available

Class Method Summary collapse

Class Method Details

.check_valid_key(key) ⇒ Object

Test if key is a recognised configuration option name. Raise an exception if it isn’t

Parameters:

  • key (Symbol)

    Option name



28
29
30
31
32
# File 'lib/translatomatic/config/options.rb', line 28

def check_valid_key(key)
  key = key ? key.to_sym : nil
  raise t('config.invalid_key', key: key) unless valid_key?(key)
  key
end

.option(key) ⇒ Translatomatic::Option

Returns The specified option.

Parameters:

  • key (Symbol)

    Option name

Returns:



20
21
22
23
# File 'lib/translatomatic/config/options.rb', line 20

def option(key)
  check_valid_key(key)
  options[key.to_sym]
end

.optionsHash<String,Translatomatic::Option>

Returns options.

Returns:



7
8
9
10
11
12
13
14
15
16
# File 'lib/translatomatic/config/options.rb', line 7

def options
  @config_options ||= begin
    # create mapping from option name to option object
    map = {}
    config_sources.each do |source|
      map.merge!(source_options(source))
    end
    map
  end
end

.valid_key?(key) ⇒ Boolean

Returns True if key is a recognised configuration option.

Returns:

  • (Boolean)

    True if key is a recognised configuration option



35
36
37
# File 'lib/translatomatic/config/options.rb', line 35

def valid_key?(key)
  options.include?(key.to_sym)
end