Sha256: cc07ecff586c37a60366d5707f0bffa0d227903189abda4015d641177e2a779f

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

require "hanami/router"
require "hanami/api/block/context"

module Hanami
  class API
    # @since 0.1.0
    class Router < ::Hanami::Router
      # @since 0.1.0
      # @api private
      def initialize(stack:, **kwargs, &blk)
        @stack = stack
        super(block_context: Block::Context, **kwargs, &blk)
      end

      # @since 0.1.0
      # @api private
      def freeze
        return self if frozen?

        remove_instance_variable(:@stack)
        super
      end

      # @since 0.1.0
      # @api private
      def use(middleware, *args, &blk)
        @stack.use(middleware, args, &blk)
      end

      # @since 0.1.0
      # @api private
      def scope(*args, **kwargs, &blk)
        @stack.with(args.first) do
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-api-0.1.0 lib/hanami/api/router.rb