module Roda::RodaPlugins::MultiRun::ClassMethods
Public Instance Methods
Source
# File lib/roda/plugins/multi_run.rb, line 76 def freeze app_blocks = opts[:multi_run_app_blocks] apps = opts[:multi_run_apps] app_blocks.each do |prefix, block| apps[prefix] = block.call end app_blocks.clear.freeze apps.freeze self::RodaRequest.refresh_multi_run_regexp! super end
Convert app blocks into apps by calling them, in order to force autoloads and to speed up subsequent calls. Freeze the multi_run apps so that there can be no thread safety issues at runtime.
Calls superclass method
Source
# File lib/roda/plugins/multi_run.rb, line 90 def multi_run_apps opts[:multi_run_apps] end
Hash storing rack applications to dispatch to, keyed by the prefix for the application.
Source
# File lib/roda/plugins/multi_run.rb, line 99 def run(prefix, app=nil, &block) prefix = prefix.to_s if app raise Roda::RodaError, "cannot provide both app and block to Roda.run" if block opts[:multi_run_apps][prefix] = app opts[:multi_run_app_blocks].delete(prefix) elsif block opts[:multi_run_apps].delete(prefix) opts[:multi_run_app_blocks][prefix] = block else opts[:multi_run_apps].delete(prefix) opts[:multi_run_app_blocks].delete(prefix) end self::RodaRequest.refresh_multi_run_regexp! end
Add a rack application to dispatch to for the given prefix when r.multi_run is called. If a block is given, it is called every time there is a request for the route to get the app to call. If neither a block or an app is provided, any stored route for the prefix is removed. It is an error to provide both an app and block in the same call.