Module: CommonMarker::Config
- Defined in:
- lib/commonmarker/config.rb
Overview
For Ruby::Enum, these must be classes, not modules
Defined Under Namespace
Class Method Summary collapse
Class Method Details
.check_option(option, type) ⇒ Object
46 47 48 49 50 |
# File 'lib/commonmarker/config.rb', line 46 def self.check_option(option, type) unless type.key?(option) raise TypeError, "option ':#{option}' does not exist for #{type}" end end |
.process_options(option, type) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/commonmarker/config.rb', line 32 def self.(option, type) type = Config.const_get(type.capitalize) if option.is_a?(Symbol) check_option(option, type) type.to_h[option] elsif option.is_a?(Array) option = [nil] if option.empty? # neckbearding around. the map will both check the opts and then bitwise-OR it option.map { |o| check_option(o, type); type.to_h[o] }.inject(0, :|) else raise TypeError, "option type must be a valid symbol or array of symbols within the #{type} context" end end |