Sha256: c97f199ddcff4f6f41c43154f0e99e7ea1de6ac1d9e9d6446477f3fffd85c4ef

Contents?: true

Size: 777 Bytes

Versions: 8

Compression:

Stored size: 777 Bytes

Contents

require 'rack/request'
require 'useless/doc/ui/godel'

module Useless
  module Doc
    module Rack

      # +Doc::Rack::UI+ chooses which UI should be used to render the
      # documentation. It can theoretically be chosen via the 'ui' parameter,
      # but for now it will alway choose +Godel+
      #
      class UI
        def self.default
          Useless::Doc::UI::Godel
        end

        def initialize(app)
          @app = app
        end

        def call(env)
          request = ::Rack::Request.new(env)

          ui = case request.params['ui']
          when 'godel' then Useless::Doc::UI::Godel
          else              Rack::UI.default
          end

          env['useless.doc.ui'] = ui
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
useless-doc-0.2.3 lib/useless/doc/rack/ui.rb
useless-doc-0.2.2 lib/useless/doc/rack/ui.rb
useless-doc-0.2.1 lib/useless/doc/rack/ui.rb
useless-doc-0.2.0 lib/useless/doc/rack/ui.rb
useless-doc-0.1.3 lib/useless/doc/rack/ui.rb
useless-doc-0.1.2 lib/useless/doc/rack/ui.rb
useless-doc-0.1.1 lib/useless/doc/rack/ui.rb
useless-doc-0.1.0 lib/useless/doc/rack/ui.rb