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
49 50 51 |
# File 'lib/commonmarker/config.rb', line 49 def self.check_option(option, type) raise TypeError, "option ':#{option}' does not exist for #{type}" unless type.key?(option) end |
.process_options(option, type) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 do |o| check_option(o, type) type.to_h[o] end.inject(0, :|) else raise TypeError, "option type must be a valid symbol or array of symbols within the #{type} context" end end |