Class: Hanami::Providers::Routes Private

Inherits:
Dry::System::Provider::Source
  • Object
show all
Defined in:
lib/hanami/providers/routes.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provider source to register routes helper component in Hanami slices.

See Also:

Since:

  • 2.0.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_slice(slice) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



14
15
16
17
18
# File 'lib/hanami/providers/routes.rb', line 14

def self.for_slice(slice)
  Class.new(self) do |klass|
    klass.instance_variable_set(:@slice, slice)
  end
end

.sliceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



21
22
23
# File 'lib/hanami/providers/routes.rb', line 21

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

Instance Method Details

#prepareObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



26
27
28
# File 'lib/hanami/providers/routes.rb', line 26

def prepare
  require "hanami/slice/routes_helper"
end

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



31
32
33
34
35
36
37
38
# File 'lib/hanami/providers/routes.rb', line 31

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