Sha256: 44d1f08422f4b6511fa9c430edd2215e5832c9fe6429ad69ae2ef1133c9ddccb

Contents?: true

Size: 704 Bytes

Versions: 20

Compression:

Stored size: 704 Bytes

Contents

module Shogun
  class Dispatch
    class Route
      require_relative "route/null"

      attr_reader :control

      def initialize(namespace:, verb:, matcher:, control:)
        @namespace = namespace
        @verb = verb
        @matcher = matcher
        @control = control
      end

      def as_key
        if expression? then Regexp.new("^#{verb} /#{path}$") else "#{verb} /#{path}" end
      end

      private def path
        @path ||= [@namespace, @matcher].compact.join("/")
      end

      private def verb
        @verb.to_s.upcase
      end

      private def expression?
        [@namespace, @matcher].any? do |item|
          item.is_a?(Regexp)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shogun-6.4.2 lib/shogun/dispatch/route.rb
shogun-6.4.1 lib/shogun/dispatch/route.rb
shogun-6.4.0 lib/shogun/dispatch/route.rb
shogun-6.3.0 lib/shogun/dispatch/route.rb
shogun-6.2.3 lib/shogun/dispatch/route.rb
shogun-6.2.2 lib/shogun/dispatch/route.rb
shogun-6.2.1 lib/shogun/dispatch/route.rb
shogun-6.2.0 lib/shogun/dispatch/route.rb
shogun-6.1.0 lib/shogun/dispatch/route.rb
shogun-6.0.0 lib/shogun/dispatch/route.rb
shogun-4.0.1 lib/shogun/dispatch/route.rb
shogun-4.0.0 lib/shogun/dispatch/route.rb
shogun-3.4.0 lib/shogun/dispatch/route.rb
shogun-3.2.0 lib/shogun/dispatch/route.rb
shogun-3.1.0 lib/shogun/dispatch/route.rb
shogun-3.0.0 lib/shogun/dispatch/route.rb
shogun-2.1.1 lib/shogun/dispatch/route.rb
shogun-2.1.0 lib/shogun/dispatch/route.rb
shogun-2.0.0 lib/shogun/dispatch/route.rb
shogun-1.0.0 lib/shogun/dispatch/route.rb