Skip to content
Myr

One instance of a Plugin per request

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 6fc5e7d · Browse files · 5 files+34 added−23 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+34 added−23 removed

  • tests:+0 added−7 removed
  • other:+34 added−16 removed

5 files+34 added−23 removed

modified:lib/express/plugins/cookie.js+4 added-4 removed
modified:lib/express/plugins/hooks.js+20 added-4 removed
modified:lib/express/plugins/redirect.js+4 added-4 removed
modified:lib/express/plugin.js+6 added-4 removed
31 unmodified lines
32 */3334exports.trigger = function(name, data) {35 $(Express.plugins).each(function(plugin){36 plugin.trigger(new Event(name, data))36 (new plugin.klass(plugin.options)).trigger(new Event(name, data))37 })38}3940/**41 * Push an instance of _plugin_ with _options_42 * to the plugin stack.41 * Push _plugin_ with _options_ to the plugin stack.42 *43 * @param {Plugin} plugin44 * @param {hash} options45 * @api public46 */4748exports.use = function(plugin, options) {50 Express.plugins.push(new plugin(options))49 Express.plugins.push({50 klass: plugin,51 options: options 52 })53}5455// --- Plugin56
27 unmodified lines
modified:spec/spec.plugins.js-7 removed
13 unmodified lines
14 reset()15 use(CSSColors)16 end17 18 describe 'with options provided'19 it 'should merge properties'20 use(CSSColors, { foo: 'bar' })21 $(Express.plugins).last().should.have_property 'foo', 'bar'22 end23 end24 18 describe 'Event'19 describe '#init()'20 it 'should accept arbitrary data'21 var event = new Event('foo', { bar: 'baz' })
18 unmodified lines