Sha256: fd4aec0040734f2b784faf99c24ef962b581aa3029fb408ac2da152377e946fd

Contents?: true

Size: 515 Bytes

Versions: 1

Compression:

Stored size: 515 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Middleware
    class Router
      def call(task)
        route = task.job.class.route

        case result = route.invoke(Addressable::URI.parse(task.url))
        when Routing::Result::Mismatch
          return
        when Routing::Result::Match
          task.metadata.action = result.action
          task.metadata.params = ActiveSupport::HashWithIndifferentAccess.new(result.params)
        end

        yield if block_given?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wayfarer-0.4.1 lib/wayfarer/middleware/router.rb