Sha256: e1d0e654472aa39902b478c54bf2beb4efe76ea86f23dd810b97ba00287547a2

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

require "dry/system/provider/source"

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

4 entries across 4 versions & 1 rubygems

Version Path
hanami-2.0.0.beta3 lib/hanami/providers/routes.rb
hanami-2.0.0.beta2 lib/hanami/providers/routes.rb
hanami-2.0.0.beta1.1 lib/hanami/providers/routes.rb
hanami-2.0.0.beta1 lib/hanami/providers/routes.rb