Commits

Michael Granger committed 0027480

Change filter plugin order; change run_before/run_after to run_outside/run_inside.

- Backward-compatibility maintained with an alias.

  • Participants
  • Parent commits 662737a

Comments (0)

Files changed (12)

File Plugins.rdoc

 == Load Order
 
 The request is passed through plugins sequentually.  You can control where in
-the chain your plugin belongs, by using the <tt>run_before</tt> and
-<tt>run_after</tt> methods.  Both methods accept a comma separated list of other
+the chain your plugin belongs, by using the <tt>run_outside</tt> and
+<tt>run_inside</tt> methods.  Both methods accept a comma separated list of other
 plugin names.
 
 In this example case, we want the logger to log the request before the other
     module Strelka::App::DBLogger
         extend Strelka::Plugin
 
-        run_before :auth,
+        run_outside :auth,
             :filters,
             :negotiation,
             :parameters,
     module Strelka::App::DBLogger
         extend Strelka::Plugin
 
-        run_before :auth,
+        run_outside :auth,
             :filters,
             :negotiation,
             :parameters,

File lib/strelka/app/auth.rb

 	config_key :auth
 
 	# Plugins API -- Set up load order
-	run_before :routing, :restresources
-	run_after  :templating, :errors, :sessions
+	run_outside :routing, :restresources
+	run_inside  :templating, :errors, :sessions
 
 
 	# The name of the default plugin to use for authentication

File lib/strelka/app/errors.rb

 
 
 	# Plugin load order
-	run_before :routing
+	run_outside :routing
 
 
 	# Class-level functionality

File lib/strelka/app/filters.rb

 module Strelka::App::Filters
 	extend Strelka::Plugin
 
-	run_before :routing, :templating
+	run_inside  :templating
+	run_outside :routing
 
 
 	# Class methods to add to classes with routing.

File lib/strelka/app/negotiation.rb

 	include Strelka::Constants
 	extend Strelka::Plugin
 
-	run_before :routing
-	run_after  :filters, :templating, :parameters
+	run_outside :routing, :filters
+	run_inside  :templating, :parameters
 
 
 	# Class methods to add to classes with content-negotiation.

File lib/strelka/app/parameters.rb

 module Strelka::App::Parameters
 	extend Strelka::Plugin
 
-	run_before :routing
-	run_after :filters
+	run_outside :routing, :filters
 
 
 	# Class methods to add to classes with routing.

File lib/strelka/app/routing.rb

 	log_to :strelka
 
 	# Plugins API -- set up load order
-	run_after :templating, :filters, :parameters
+	run_inside :templating, :filters, :parameters
 
 
 	# Class methods to add to classes with routing.

File lib/strelka/app/sessions.rb

 	# Configurability API -- specify which section of the config this class gets
 	config_key :sessions
 
-	# Plugins API -- Specify load order; run as late as possible so other plugins
+	# Plugins API -- Specify load order; run as early as possible so other plugins
 	# can use the session
-	run_after :templating, :filters, :parameters
+	run_outside :templating, :filters, :parameters
 
 
 	# Class methods and instance variables to add to classes with sessions.

File lib/strelka/app/templating.rb

 	log_to :strelka
 
 	# Run order
-	run_before :routing, :negotiation, :errors
-	run_after :filters
+	run_outside :routing, :negotiation, :errors, :filters
 
 
 	### Return an Array of Pathnames to all directories named 'templates' under the

File lib/strelka/plugins.rb

 			name = object.plugin_name
 			if (( deps = pluggable.loaded_plugins[name] ))
 				self.log.debug "  installing deferred deps for %p" % [ name ]
-				object.run_after( *deps )
+				object.run_inside( *deps )
 			end
 
 			self.log.debug "  adding %p (%p) to the plugin registry for %p" %
 
 		### Register the receiver as needing to be run before +other_plugins+ for requests, and
 		### *after* them for responses.
-		def run_before( *other_plugins )
+		def run_outside( *other_plugins )
 			name = self.plugin_name
 			other_plugins.each do |other_name|
 				self.pluggable.loaded_plugins[ other_name ] ||= []
 				mod = self.pluggable.loaded_plugins[ other_name ]
 
-				if mod.respond_to?( :run_after )
-					mod.run_after( name )
+				if mod.respond_to?( :run_inside )
+					mod.run_inside( name )
 				else
 					self.log.debug "%p plugin not yet loaded; setting up pending deps" % [ other_name ]
 					mod << name
 				end
 			end
 		end
+		alias_method :run_before, :run_outside
 
 
 		### Register the receiver as needing to be run after +other_plugins+ for requests, and
 		### *before* them for responses.
-		def run_after( *other_plugins )
+		def run_inside( *other_plugins )
 			self.log.debug "  %p will run after %p" % [ self, other_plugins ]
 			self.successors.merge( other_plugins )
 		end
+		alias_method :run_after, :run_inside
 
 	end # module Plugin
 
 
 
 		### Install the mixin part of the plugin, in the order determined by
-		### the plugin registry based on the run_before and run_after specifications
+		### the plugin registry based on the run_outside and run_inside specifications
 		### of the plugins themselves.
 		def install_plugins
 			if self.plugins_installed?

File lib/strelka/websocketserver/routing.rb

 	log_to :strelka
 
 	# Plugins API -- set up load order
-	# run_after :templating, :filters, :parameters
+	# run_inside :templating, :filters, :parameters
 
 
 	# Class methods to add to classes with routing.

File spec/strelka/plugins_spec.rb

 				@before_mod = Module.new do
 					def self::name; "Strelka::Pluggable::BeforeTestPlugin"; end
 					extend Strelka::Plugin
-					run_before( modname )
+					run_outside( modname )
 				end
 			end
 
 				@after_mod = Module.new do
 					def self::name; "Strelka::Pluggable::AfterTestPlugin"; end
 					extend Strelka::Plugin
-					run_after( modname )
+					run_inside( modname )
 				end
 			end
 
 			@templating_plugin = Module.new do
 				def self::name; "Strelka::Pluggable::Templating"; end
 				extend Strelka::Plugin
-				run_before :routing
+				run_outside :routing
 			end
 		end