Sha256: b1b2cc27fc021fbed4a28cb844e15d59c3f1683aa01f3a1b22c8fcdadceb0948

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

module Typekit
  module Routing
    module Node
      class Base
        def append(child)
          children << child
        end

        def assemble(request, path)
          process(request, path)
          return authorize(request) if path.empty?
          lookup!(path.first).assemble(request, path)
        end

        def match(name)
        end

        def process(request, path)
        end

        def permitted?(request)
        end

        protected

        def children
          @children ||= []
        end

        def lookup(name)
          children.find { |c| c.match(name) }
        end

        def lookup!(name)
          lookup(name) or raise Error, 'Not found'
        end

        def authorize(request)
          raise Error, 'Not permitted' unless permitted?(request)
          request
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typekit-client-0.0.2 lib/typekit/routing/node/base.rb