Sha256: a238b0381d98b9d52ea130b52077f2604a42b5dc038d43966bc088f19b95da69

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

class Renee
  class Core
    class Application
      # A module that defines useful Rack interaction methods.
      module RackInteraction

        # Creates an ad-hoc Rack application within the context of a Rack::Builder.
        # @example
        #     get { halt build { use Rack::ContentLength; run proc { |env| Rack::Response.new("Hello!").finish } } }
        #
        def build(&blk)
          run Rack::Builder.new(&blk).to_app
        end

        def build!(&blk)
          run! build(&blk)
        end

        # Runs a rack application
        # @example
        #     get { halt run proc { |env| Renee::Core::Response.new("Hello!").finish } }
        #
        def run(app = nil, &blk)
          (app || blk).call(env)
        end

        # Runs a rack application and responds immediately.
        #
        # @see #run
        # @example
        #     get { run proc { |env| Renee::Core::Response.new("Hello!").finish } }
        #
        def run!(*args)
          halt! run(*args)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renee-core-0.0.1 lib/renee-core/application/rack_interaction.rb