Sha256: 2a5e820bfe2c1676dfbefb6773fa39a915a76785ee7577950081d19588637829

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require "mustermann/rails"

module Hanami
  class Router
    class Leaf
      # Trie Leaf
      #
      # @api private
      # @since 2.2.0
      attr_reader :to, :params

      # @api private
      # @since 2.2.0
      def initialize(route, to, constraints)
        @route = route
        @to = to
        @constraints = constraints
        @params = nil
      end

      # @api private
      # @since 2.2.0
      def match(path)
        match = matcher.match(path)

        @params = match.named_captures if match

        match
      end

      private

      # @api private
      # @since 2.2.0
      def matcher
        @matcher ||= Mustermann.new(@route, type: :rails, version: "5.0", capture: @constraints)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-router-2.2.0 lib/hanami/router/leaf.rb