Sha256: 75b68fc480533e3058944821fe2f82a4b0f9127cd7dab7d08e64c97ba5b70aea
Contents?: true
Size: 793 Bytes
Versions: 5
Compression:
Stored size: 793 Bytes
Contents
# frozen_string_literal: true module Grape class Router class BaseRoute delegate_missing_to :@options attr_reader :index, :pattern, :options def initialize(**options) @options = ActiveSupport::OrderedOptions.new.update(options) end alias attributes options def regexp_capture_index CaptureIndexCache[index] end def pattern_regexp pattern.to_regexp end def to_regexp(index) @index = index Regexp.new("(?<#{regexp_capture_index}>#{pattern_regexp})") end class CaptureIndexCache < Grape::Util::Cache def initialize super @cache = Hash.new do |h, index| h[index] = "_#{index}" end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems