Sha256: 44fc0f046ad0bd2c80a82e996288417d0d39f3e6f686df966d6661fb31d19077
Contents?: true
Size: 954 Bytes
Versions: 1
Compression:
Stored size: 954 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) # Return absolute paths as is return path if path.is_a?(String) && path.start_with?("http") @definition.resolve(path) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
staticky-0.1.1 | lib/staticky/router.rb |