Class: Hanami::API::Router

Inherits:
Router
  • Object
show all
Defined in:
lib/hanami/api/router.rb

Overview

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block_context: Block::Context, inspector: Inspector.new, **kwargs) ⇒ Router

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.

Returns a new instance of Router.

Since:

  • 0.1.0



17
18
19
20
# File 'lib/hanami/api/router.rb', line 17

def initialize(block_context: Block::Context, inspector: Inspector.new, **kwargs)
  super(block_context: block_context, inspector: inspector, **kwargs)
  @stack = Middleware::Stack.new(@path_prefix.to_s)
end

Instance Attribute Details

#inspectorObject (readonly)

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:

  • x.x.x



13
14
15
# File 'lib/hanami/api/router.rb', line 13

def inspector
  @inspector
end

Instance Method Details

#freezeObject

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:

  • 0.1.0



24
25
26
27
28
29
# File 'lib/hanami/api/router.rb', line 24

def freeze
  return self if frozen?

  remove_instance_variable(:@stack)
  super
end

#to_inspectString

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.

Returns formatted routes

Returns:

  • (String)

    formatted routes

Since:

  • x.x.x



49
50
51
# File 'lib/hanami/api/router.rb', line 49

def to_inspect
  @inspector.call
end

#to_rack_appObject

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:

  • 0.1.1



39
40
41
# File 'lib/hanami/api/router.rb', line 39

def to_rack_app
  @stack.finalize(self)
end

#use(middleware, *args, &blk) ⇒ 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:

  • 0.1.0



33
34
35
# File 'lib/hanami/api/router.rb', line 33

def use(middleware, *args, &blk)
  @stack.use(@path_prefix.to_s, middleware, *args, &blk)
end