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
-
.check_valid_key(key) ⇒ Object
Test if key is a recognised configuration option name.
-
.option(key) ⇒ Translatomatic::Option
The specified option.
-
.options ⇒ Hash<String,Translatomatic::Option>
Options.
-
.valid_key?(key) ⇒ Boolean
True if key is a recognised configuration option.
Class Method Details
.check_valid_key(key) ⇒ Object
Test if key is a recognised configuration option name. Raise an exception if it isn’t
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.
20 21 22 23 |
# File 'lib/translatomatic/config/options.rb', line 20 def option(key) check_valid_key(key) [key.to_sym] end |
.options ⇒ Hash<String,Translatomatic::Option>
Returns options.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/translatomatic/config/options.rb', line 7 def @config_options ||= begin # create mapping from option name to option object map = {} config_sources.each do |source| map.merge!((source)) end map end end |
.valid_key?(key) ⇒ Boolean
Returns True if key is a recognised configuration option.
35 36 37 |
# File 'lib/translatomatic/config/options.rb', line 35 def valid_key?(key) .include?(key.to_sym) end |