Class: Hanami::CLI::MiddlewareStackInspector Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/cli/middleware_stack_inspector.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.

Since:

  • 2.0.0

Instance Method Summary collapse

Constructor Details

#initialize(stack:) ⇒ MiddlewareStackInspector

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 MiddlewareStackInspector.

Since:

  • 2.0.0



10
11
12
# File 'lib/hanami/cli/middleware_stack_inspector.rb', line 10

def initialize(stack:)
  @stack = stack
end

Instance Method Details

#inspect(include_arguments: false) ⇒ 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



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hanami/cli/middleware_stack_inspector.rb', line 16

def inspect(include_arguments: false)
  max_path_length = @stack.map { |(path)| path.length }.max

  @stack.map { |path, middleware|
    middleware.map { |(mware, arguments)|
      "#{path.ljust(max_path_length + 3)} #{format_middleware(mware)}".tap { |line|
        line << " #{format_arguments(arguments)}" if include_arguments
      }
    }
  }.join("\n") + "\n"
end