Sha256: b4e4d3d7a3ff7d852457841a356b0e14cce58f4af4415b92693e32a4a3dba055

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module Staticky
  class Router
    # DOCS: Holds routes as a class instance variable. This class is expected to
    # be used as a singleton by requiring the "routes.rb" file.
    #
    # NOTE: Why do we need our own router? Why not just use Roda for these
    # definitions? Roda is a routing tree and cannot be introspected easily.
    # In Staticky when we build we need to do a lot of introspection to link
    # routes to resources on the file system.

    def initialize
      @definition = Staticky::Router::Definition.new
    end

    def define(&block)
      tap do
        @definition.instance_eval(&block)
      end
    end

    def filepaths
      @definition.filepaths
    end

    def resources
      @definition.resources
    end

    def resolve(path)
      @definition.resolve(path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
staticky-0.1.0 lib/staticky/router.rb