module CommonMarker::Config

For Ruby::Enum, these must be classes, not modules

Public Class Methods

check_option(option, type) click to toggle source
# File lib/commonmarker/config.rb, line 43
def self.check_option(option, type)
  unless type.keys.include?(option)
    raise TypeError, "option ':#{option}' does not exist for #{type}"
  end
end
process_options(option, type) click to toggle source
# File lib/commonmarker/config.rb, line 29
def self.process_options(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'
  end
end