Module: Renee::Core::RackInteraction
- Included in:
- Renee::Core
- Defined in:
- lib/renee_core/rack_interaction.rb
Overview
A module that defines useful Rack interaction methods.
Instance Method Summary collapse
-
#build { ... } ⇒ Object
Creates an ad-hoc Rack application within the context of a Rack::Builder.
-
#build!(&blk) ⇒ Object
Creates an ad-hoc Rack application within the context of a Rack::Builder that immediately halts when done.
-
#run(app = nil) {|env| ... } ⇒ Object
Runs a rack application.
-
#run!(app = nil, &blk) ⇒ Object
Runs a rack application and halts immediately.
Instance Method Details
#build { ... } ⇒ Object
Creates an ad-hoc Rack application within the context of a Rack::Builder.
11 12 13 |
# File 'lib/renee_core/rack_interaction.rb', line 11 def build(&blk) run Rack::Builder.new(&blk).to_app end |
#build!(&blk) ⇒ Object
Creates an ad-hoc Rack application within the context of a Rack::Builder that immediately halts when done.
21 22 23 |
# File 'lib/renee_core/rack_interaction.rb', line 21 def build!(&blk) halt build(&blk) end |
#run(app = nil) {|env| ... } ⇒ Object
Runs a rack application. You must either use app
or blk
.
33 34 35 36 |
# File 'lib/renee_core/rack_interaction.rb', line 33 def run(app = nil, &blk) raise "You cannot supply both a block and an app" unless app.nil? ^ blk.nil? (app || blk).call(env) end |
#run!(app = nil, &blk) ⇒ Object
Runs a rack application and halts immediately.
45 46 47 |
# File 'lib/renee_core/rack_interaction.rb', line 45 def run!(app = nil, &blk) halt run(app, &blk) end |