lib/roda/plugins/multi_run.rb in roda-1.2.0 vs lib/roda/plugins/multi_run.rb in roda-1.3.0

- old
+ new

@@ -32,23 +32,29 @@ # variables in the main Roda app and have those instance variables usable in # the routing subtrees. module MultiRun # Initialize the storage for the dispatched applications def self.configure(app) - app.instance_eval do - @multi_run_apps ||= {} - end + app.opts[:multi_run_apps] ||= {} end module ClassMethods + # Freeze the multi_run apps so that there can be no thread safety issues at runtime. + def freeze + opts[:multi_run_apps].freeze + super + end + # Hash storing rack applications to dispatch to, keyed by the prefix # for the application. - attr_reader :multi_run_apps + def multi_run_apps + opts[:multi_run_apps] + end # Add a rack application to dispatch to for the given prefix when # r.multi_run is called. def run(prefix, app) - @multi_run_apps[prefix.to_s] = app + multi_run_apps[prefix.to_s] = app self::RodaRequest.refresh_multi_run_regexp! end end module RequestClassMethods