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