Use the new statics: true setting for Base injection, and fix Array.prototype.slice issue in Base.read().

This commit is contained in:
Jürg Lehni 2011-03-05 14:23:42 +00:00
parent 3f0a45a7c2
commit cfb7d195c0

View file

@ -13,27 +13,27 @@ this.install = function(scope) {
//#include "../lib/bootstrap.js"
Base.inject({
statics: {
read: function(args, index, length) {
var index = index || 0, length = length || args.length - index;
if (length <= 1) {
var arg = args[index];
// Return null when nothing was provided
if (arg instanceof this || arg == null)
return arg;
}
var obj = new this(this.dont);
obj = obj.initialize.apply(obj, index > 0 || length < args.length
? slice.call(args, index, index + length)
: args) || obj;
return obj;
},
statics: true,
capitalize: function(str) {
return str.replace(/\b[a-z]/g, function(match) {
return match.toUpperCase();
});
read: function(args, index, length) {
var index = index || 0, length = length || args.length - index;
if (length <= 1) {
var arg = args[index];
// Return null when nothing was provided
if (arg instanceof this || arg == null)
return arg;
}
var obj = new this(this.dont);
obj = obj.initialize.apply(obj, index > 0 || length < args.length
? Array.prototype.slice.call(args, index, index + length)
: args) || obj;
return obj;
},
capitalize: function(str) {
return str.replace(/\b[a-z]/g, function(match) {
return match.toUpperCase();
});
}
});