Sha256: 6f40a8fc3bf59b4e245f07552dd9c8a44173778d2948fa5c4db3d41e8fd4716f
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Hanami class API module Middleware # Trie node to register scopes with custom Rack middleware # # @api private # @since 0.1.1 class Node # @api private # @since 0.1.1 attr_reader :app # @api private # @since 0.1.1 def initialize @app = nil @children = {} end # @api private # @since 0.1.1 def freeze @children.each(&:freeze) super end # @api private # @since 0.1.1 def put(segment) @children[segment] ||= self.class.new end # @api private # @since 0.1.1 def get(segment) @children.fetch(segment) { self if leaf? } end # @api private # @since 0.1.1 def app!(app) @app = app end # @api private # @since 0.1.1 def app? @app end # @api private # @since 0.1.1 def leaf? @children.empty? end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanami-api-0.2.0 | lib/hanami/api/middleware/node.rb |
hanami-api-0.1.2 | lib/hanami/api/middleware/node.rb |
hanami-api-0.1.1 | lib/hanami/api/middleware/node.rb |