Sha256: 701237858802c72856a15e01af5ba86e6d1d19d6f6e235181615d1bbe68d5914
Contents?: true
Size: 1.11 KB
Versions: 13
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require "hanami/router/formatter/human_friendly" module Hanami class Router # Builds a representation of an array of routes according to a given formatter. # # @see Router.new # # @since 2.0.0 # @api private class Inspector # @param routes [Array<Hanami::Route>] # @param formatter [#call] routes formatter, taking routes as an argument and returning its # own representation (typically a string). Defaults to {Formatter::HumanFriendly}. # # @since 2.0.0 # @api public def initialize(routes: [], formatter: Formatter::HumanFriendly.new) @routes = routes @formatter = formatter end # Adds a route to be inspected. # # @param route [Route] # # @since 2.0.0 # @api public def add_route(route) @routes.push(route) end # Calls the formatter for all added routes. # # @return [Any] Formatted routes # # @since 2.0.0 # @api public def call(...) @formatter.call(@routes, ...) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems