Sha256: f55e7573f4f80c12b0983c3ee769be0fa10249d9f7ddd2d29af854d59b57393a

Contents?: true

Size: 981 Bytes

Versions: 16

Compression:

Stored size: 981 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

        def all_routes
          router.all_routes
        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

16 entries across 16 versions & 1 rubygems

Version Path
rasti-web-2.1.1 lib/rasti/web/application.rb
rasti-web-2.1.0 lib/rasti/web/application.rb
rasti-web-2.0.1 lib/rasti/web/application.rb
rasti-web-2.0.0 lib/rasti/web/application.rb
rasti-web-1.2.1 lib/rasti/web/application.rb
rasti-web-1.2.0 lib/rasti/web/application.rb
rasti-web-1.1.0 lib/rasti/web/application.rb
rasti-web-1.0.0 lib/rasti/web/application.rb
rasti-web-0.2.3 lib/rasti/web/application.rb
rasti-web-0.2.2 lib/rasti/web/application.rb
rasti-web-0.2.1 lib/rasti/web/application.rb
rasti-web-0.2.0 lib/rasti/web/application.rb
rasti-web-0.1.1 lib/rasti/web/application.rb
rasti-web-0.1.0 lib/rasti/web/application.rb
rasti-web-0.0.7 lib/rasti/web/application.rb
rasti-web-0.0.6 lib/rasti/web/application.rb