Sha256: 5d4081b7c2fa0e460c09504bb307bef27717ec396caee5345fa63d0113082d9a

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

module Hanami
  module Providers
    class Routes < Dry::System::Provider::Source
      def self.for_slice(slice)
        Class.new(self) do |klass|
          klass.instance_variable_set(:@slice, slice)
        end
      end

      def self.slice
        @slice || Hanami.app
      end

      def prepare
        require "hanami/slice/routes_helper"
      end

      def start
        # Register a lazy instance of RoutesHelper to ensure we don't load prematurely
        # load the router during the process of booting. This ensures the router's
        # resolver can run strict action key checks once when it runs on a fully booted
        # slice.
        register :routes do
          Hanami::Slice::RoutesHelper.new(self.class.slice.router)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-2.0.0.beta4 lib/hanami/providers/routes.rb