module Roda::RodaPlugins::SymbolClassMatchers_::ClassMethods
def _symbol_class_matcher(expected_class, obj, matcher, block, &request_class_block)
def _symbol_class_matcher(expected_class, obj, matcher, block, &request_class_block) unless obj.is_a?(expected_class) raise RodaError, "Invalid type passed to class_matcher or symbol_matcher: #{matcher.inspect}" end if obj.is_a?(Symbol) type = "symbol" meth = :"match_symbol_#{obj}" else type = "class" meth = :"_match_class_#{obj}" end case matcher when Regexp regexp = matcher consume_regexp = self::RodaRequest.send(:consume_pattern, regexp) when Symbol unless opts[:symbol_matchers] raise RodaError, "cannot provide Symbol matcher to class_matcher unless using symbol_matchers plugin: #{matcher.inspect}" end regexp, consume_regexp, matcher_block = opts[:symbol_matchers][matcher] unless regexp raise RodaError, "unregistered symbol matcher given to #{type}_matcher: #{matcher.inspect}" end block = _merge_matcher_blocks(type, obj, block, matcher_block) when Class unless opts[:class_matchers] raise RodaError, "cannot provide Class matcher to symbol_matcher unless using class_matchers plugin: #{matcher.inspect}" end regexp, consume_regexp, matcher_block = opts[:class_matchers][matcher] unless regexp raise RodaError, "unregistered class matcher given to #{type}_matcher: #{matcher.inspect}" end block = _merge_matcher_blocks(type, obj, block, matcher_block) else raise RodaError, "unsupported matcher given to #{type}_matcher: #{matcher.inspect}" end if block.is_a?(Symbol) convert_meth = block elsif block convert_meth = :"_convert_#{type}_#{obj}" define_method(convert_meth, &block) private convert_meth end array = opts[:"#{type}_matchers"][obj] = [regexp, consume_regexp, convert_meth].freeze self::RodaRequest.class_eval do class_exec(meth, array, &request_class_block) private meth end nil end