Sha256: b4fdcce4ff0dfa92e3f0379947f3ef74e85a2e3a4c3b471fe61c820a27f0bf93

Contents?: true

Size: 917 Bytes

Versions: 5

Compression:

Stored size: 917 Bytes

Contents

module Rasti
  module Web
    class Application
      class << self

        Router::VERBS.each do |verb|
          define_method verb do |*args, &block|
            router.public_send verb, *args, &block
          end
        end

        def not_found(*args, &block)
          router.not_found *args, &block
        end

        def use(*args, &block)
          rack.use *args, &block
        end

        def map(path, endpoint=nil, &block)
          rack.map path do
            run endpoint || Endpoint.new(&block)
          end
        end

        def call(env)
          app.call env
        end

        private

        def router
          @router ||= Router.new
        end

        def rack
          @rack ||= Rack::Builder.new
        end

        def app
          @app ||= to_app
        end

        def to_app
          rack.run router
          rack.to_app
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rasti-web-0.0.5 lib/rasti/web/application.rb
rasti-web-0.0.4 lib/rasti/web/application.rb
rasti-web-0.0.3 lib/rasti/web/application.rb
rasti-web-0.0.2 lib/rasti/web/application.rb
rasti-web-0.0.1 lib/rasti/web/application.rb