Sha256: 675c9613bead1911d0b60ff038e9e2659e8ef07b6171b35ac890dac20b018c96

Contents?: true

Size: 1.31 KB

Versions: 25

Compression:

Stored size: 1.31 KB

Contents

(function(can, window, undefined){
var isFunction = can.isFunction,
	isArray = can.isArray,
	makeArray = can.makeArray,

proxy = function( funcs ) {

			//args that should be curried
			var args = makeArray(arguments),
				self;

			// get the functions to callback
			funcs = args.shift();

			// if there is only one function, make funcs into an array
			if (!isArray(funcs) ) {
				funcs = [funcs];
			}
			
			// keep a reference to us in self
			self = this;
			
			
			return function class_cb() {
				// add the arguments after the curried args
				var cur = args.concat(makeArray(arguments)),
					isString, 
					length = funcs.length,
					f = 0,
					func;
				
				// go through each function to call back
				for (; f < length; f++ ) {
					func = funcs[f];
					if (!func ) {
						continue;
					}
					
					// set called with the name of the function on self (this is how this.view works)
					isString = typeof func == "string";
					
					// call the function
					cur = (isString ? self[func] : func).apply(self, cur || []);
					
					// pass the result to the next function (if there is a next function)
					if ( f < length - 1 ) {
						cur = !isArray(cur) || cur._use_call ? [cur] : cur
					}
				}
				return cur;
			}
		}
	can.Construct.proxy = can.Construct.prototype.proxy = proxy;
	
	




})(this.can, this )

Version data entries

25 entries across 13 versions & 2 rubygems

Version Path
rmails-0.2.5 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.5 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.4 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.4 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.3 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.3 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.2 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.2 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.1 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.1 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.0 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.2.0 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.6 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.6 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.5 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.5 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.4 vendor/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.4 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.3 app/assets/javascripts/canjs/can.construct.proxy.js
rmails-0.1.3 vendor/assets/javascripts/canjs/can.construct.proxy.js