in Ox.wrap, iterate over Ox.methods(Ox)

This commit is contained in:
rolux 2012-05-25 19:28:39 +02:00
parent c56b7cc9ed
commit c8cc037ef6

View file

@ -344,16 +344,12 @@ Ox.wrap = function(value, chained) {
return value; return value;
} }
}; };
Object.getOwnPropertyNames(Ox).forEach(function(name) { Ox.methods(Ox).forEach(function(method) {
if ( if (method[0] == method[0].toLowerCase()) {
['arguments', 'callee', 'caller', 'length'].indexOf(name) == -1 wrapper[method] = function() {
&& name[0] == name[0].toLowerCase()
&& Ox.isFunction(Ox[name])
) {
wrapper[name] = function() {
var args = Array.prototype.slice.call(arguments), ret; var args = Array.prototype.slice.call(arguments), ret;
args.unshift(value); args.unshift(value);
ret = Ox[name].apply(Ox, args); ret = Ox[method].apply(Ox, args);
return wrapper.chained ? Ox.wrap(ret, true) : ret; return wrapper.chained ? Ox.wrap(ret, true) : ret;
}; };
} }