vendor/components/indefinido-indemma/build/test.js in ende-0.3.13 vs vendor/components/indefinido-indemma/build/test.js in ende-0.4.0
- old
+ new
@@ -20200,30 +20200,26 @@
};
subscribers = {
belongs_to: {
foreign_key: function(resource_id) {
- var associated, association_name, current_resource_id, resource, _ref;
+ var association_name, current_resource_id, resource, _ref;
association_name = this.resource.toString();
- if (resource_id === null || resource_id === void 0) {
+ if (!resource_id) {
this.dirty = true;
this.owner[association_name] = resource_id;
return resource_id;
}
- current_resource_id = (_ref = this.owner[association_name]) != null ? _ref._id : void 0;
+ current_resource_id = (_ref = this.owner.observed[association_name]) != null ? _ref._id : void 0;
if (resource_id !== current_resource_id) {
resource = model[association_name];
if (!resource) {
console.warn("subscribers.belongs_to.foreign_key: associated factory not found for model: " + association_name);
return resource_id;
}
- associated = resource.find(resource_id);
- associated || (associated = resource({
- _id: resource_id
- }));
- this.owner.observed[association_name] = associated;
+ this.owner.observed[association_name] = null;
}
return resource_id;
},
associated_changed: function(associated) {
return this.owner.observed["" + (this.resource.toString()) + "_id"] = associated ? associated._id : null;
@@ -20257,14 +20253,16 @@
if (!resource) {
console.warn("subscribers.belongs_to.foreign_key: associated factory not found for model: " + association_name);
return associated;
}
associated = resource.find(associated_id || associated._id);
+ if (associated) {
+ return _this.owner.observed[association_name] = associated;
+ }
associated || (associated = resource({
_id: associated_id
}));
- resource.storage.store(associated._id, associated);
associated.reload();
return _this.owner.observed[association_name] = associated;
},
configurable: true,
enumerable: true
@@ -20282,12 +20280,12 @@
if (association_names) {
_results = [];
for (_i = 0, _len = association_names.length; _i < _len; _i++) {
association_name = association_names[_i];
associations_attributes = this["" + association_name + "_attributes"];
+ association = this[model.pluralize(association_name)];
if (associations_attributes && associations_attributes.length) {
- association = this[model.pluralize(association_name)];
if (!association) {
message = "has_many.nest_attributes: Association not found for " + association_name + ". \n";
message += "did you set it on model declaration? \n has_many: " + association_name + " ";
throw message;
}
@@ -20373,11 +20371,11 @@
this.has_one || (this.has_one = []);
this.belongs_to || (this.belongs_to = []);
return true;
},
create_after_hooks: function(definition) {
- var association_name, association_proxy, old_resource_id, options, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
+ var association_attributes, association_name, association_proxy, old_dirty, old_resource_id, options, resource, _i, _j, _k, _len, _len1, _len2, _name, _ref, _ref1, _ref2, _results;
options = model[this.resource.name || this.resource.toString()];
if (options.has_many) {
_ref = options.has_many;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -20386,10 +20384,15 @@
resource: resource,
parent_resource: this.resource,
parent: this
};
association_name = model.pluralize(resource);
+ association_attributes = this[association_name] || [];
+ this[_name = "" + association_name + "_attributes"] || (this[_name] = []);
+ if (association_attributes.length) {
+ this["" + association_name + "_attributes"] = this["" + association_name + "_attributes"].concat(association_attributes);
+ }
this[association_name] = $.extend(association_proxy, plural);
}
this.after('saved', callbacks.has_many.update_association);
callbacks.has_many.nest_attributes.call(this);
}
@@ -20421,19 +20424,16 @@
};
association_proxy[this.resource.toString()] = this;
this["build_" + resource] = $.proxy(singular.build, association_proxy);
this["create_" + resource] = $.proxy(singular.create, association_proxy);
old_resource_id = this["" + resource + "_id"];
+ old_dirty = this.dirty;
this["" + resource + "_id"] = null;
this.subscribe("" + resource + "_id", $.proxy(subscribers.belongs_to.foreign_key, association_proxy));
this.subscribe(resource.toString(), $.proxy(subscribers.belongs_to.associated_changed, association_proxy));
- this.resource_id = old_resource_id;
- if (this["" + resource + "_id"] && !this[resource]) {
- _results.push(this.publish("" + resource + "_id", this["" + resource + "_id"]));
- } else {
- _results.push(void 0);
- }
+ this["" + resource + "_id"] = old_resource_id;
+ _results.push(this.dirty = old_dirty);
}
return _results;
}
},
create_before_hooks: function(record) {
@@ -20504,11 +20504,18 @@
};
persistable = {
record: {
after_initialize: function() {
- return this.after('saved', handlers.store_after_saved);
+ var storage;
+
+ if (this._id) {
+ storage = model[this.resource.toString()].storage;
+ return storage.store(this._id, this);
+ } else {
+ return this.after('saved', handlers.store_after_saved);
+ }
}
}
};
model = window.model;
@@ -20546,11 +20553,11 @@
if (arguments.length === 1) {
this.reads++;
return collection[key];
} else {
this.writes++;
- value.sustained = true;
+ value.sustained || (value.sustained = true);
return collection[key] = value;
}
},
values: function() {
return Object.values(this.database);
@@ -20583,10 +20590,13 @@
stampit = require('../../vendor/stampit');
queryable = {
storage: storable(),
find: function(key) {
+ if (!key) {
+ throw new TypeError("InvalidFind: resource.find was called with a falsey value");
+ }
return this.storage.store(key);
},
all: function() {
return this.storage.values();
},
@@ -20607,11 +20617,11 @@
return extend(modelable, queryable);
});
});
require.register("indemma/lib/record/resource.js", function(exports, require, module){
-var model, resource, resourceable, stampit;
+var descriptors, model, resource, resourceable, stampit;
stampit = require('../../vendor/stampit');
require('../../vendor/owl/pluralize');
@@ -20634,38 +20644,15 @@
}
this.param_name || (this.param_name = this.name);
return this;
});
-resourceable = {
- pluralize: function(word, count, plural) {
- if (!(word && word.length)) {
- throw new TypeError("Invalid string passed to pluralize '" + word + "'");
- }
- if (word.indexOf('s') !== word.length - 1) {
- return owl.pluralize(word, count, plural);
- } else {
- return word;
- }
- },
- singularize: function(word) {
- if (!(word && word.length)) {
- throw new TypeError("Invalid string passed to singularize '" + word + "'");
- }
- if (word.lastIndexOf('s') === word.length - 1) {
- return word.substring(0, word.length - 1);
- } else {
- return word;
- }
- },
+descriptors = {
route: {
get: function() {
var route;
- if (this.initial_route != null) {
- return this.initial_route;
- }
if (typeof this.resource === 'string') {
this.resource = {
name: this.resource
};
}
@@ -20675,37 +20662,40 @@
}
if (this.resource.scope != null) {
route += this.resource.scope + '/';
}
route += this.resource.singular ? this.resource.name : model.pluralize(this.resource.name);
- this.initial_route = route;
- return route;
+ return this.route = route;
},
- set: function(value) {
- return this.initial_route = value;
+ configurable: true
+ }
+};
+
+resourceable = {
+ pluralize: function(word, count, plural) {
+ if (!(word && word.length)) {
+ throw new TypeError("Invalid string passed to pluralize '" + word + "'");
}
+ if (word.indexOf('s') !== word.length - 1) {
+ return owl.pluralize(word, count, plural);
+ } else {
+ return word;
+ }
},
- parent_id: {
- get: function() {
- if (this[this.parent_resource]) {
- return this[this.parent_resource]._id;
- }
- },
- set: function() {
- return console.error('Warning changing associations throught parent_id not allowed for security and style guide purposes');
+ singularize: function(word) {
+ if (!(word && word.length)) {
+ throw new TypeError("Invalid string passed to singularize '" + word + "'");
}
+ if (word.lastIndexOf('s') === word.length - 1) {
+ return word.substring(0, word.length - 1);
+ } else {
+ return word;
+ }
},
initialize: function() {
var resource_definition, _ref;
- if (this.parent_resource) {
- Object.defineProperty(this, "" + this.parent_resource + "_id", {
- value: resourceable.parent_id,
- configurable: true,
- enumerable: true
- });
- }
resource_definition = {};
if (typeof this.resource === 'string') {
resource_definition = {
name: this.resource
};
@@ -20714,11 +20704,11 @@
this.resource.original_reference = this.resource;
resource_definition = this.resource;
}
resource_definition.parent = this.parent_resource;
this.resource = resource(resource_definition);
- return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route', resourceable.route);
+ return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route', descriptors.route);
}
};
model = window.model;
@@ -20773,11 +20763,11 @@
});
};
});
require.register("indemma/lib/record/restfulable.js", function(exports, require, module){
-var $, merge, model, observable, record, rest, restful, type, util,
+var $, merge, model, observable, record, rest, restful, root, type, util,
__slice = [].slice;
merge = require('assimilate').withStrategy('deep');
type = require('type');
@@ -20786,19 +20776,21 @@
$ = require('jquery');
rest = require('./rest.js');
+root = typeof exports !== "undefined" && exports !== null ? exports : this;
+
util = {
model: {
- map: function(models) {
- var model, _i, _len, _results;
+ map: function(records) {
+ var record, _i, _len, _results;
_results = [];
- for (_i = 0, _len = models.length; _i < _len; _i++) {
- model = models[_i];
- _results.push(this(model));
+ for (_i = 0, _len = records.length; _i < _len; _i++) {
+ record = records[_i];
+ _results.push(this(record));
}
return _results;
}
}
};
@@ -20826,19 +20818,19 @@
record.dirty = true;
savings.push(record.save(callback));
}
return $.when.apply($, savings);
},
- all: function(conditions, callback) {
+ all: function(conditions, doned, failed) {
if (conditions == null) {
conditions = {};
}
if (typeof conditions === 'function') {
- callback = conditions;
+ doned = conditions;
conditions = {};
}
- return $.when(rest.get.call(this, conditions)).then(util.model.map).done(callback);
+ return $.when(rest.get.call(this, conditions)).then(util.model.map).done(doned).fail(failed);
},
first: function(conditions, callback) {
var namespaced;
if (conditions == null) {
@@ -20852,19 +20844,25 @@
namespaced.limit = 1;
namespaced.order = 'desc';
return this.all(conditions, callback);
},
get: function(action, data) {
- var old_route, payload, promise, resource, route;
+ var default_route, old_route, payload, promise, resource;
if (data == null) {
data = {};
}
old_route = this.route;
- this.route = "/" + (model.pluralize(this.resource.name));
+ default_route = "/" + (model.pluralize(this.resource.name));
+ if (default_route !== this.route) {
+ this.route = default_route;
+ }
if (action) {
- this.route += "/" + action;
+ Object.defineProperty(this, 'route', {
+ value: "" + default_route + "/" + action,
+ configurable: true
+ });
}
resource = data.resource;
if (data && data.json) {
data = data.json();
}
@@ -20872,17 +20870,23 @@
payload = data;
data = {};
data[resource] = payload;
}
promise = rest.get.call(this, data);
- route = old_route;
+ Object.defineProperty(this, 'route', {
+ value: old_route,
+ configurable: true
+ });
return promise;
},
put: rest.put,
"delete": rest["delete"]
},
record: {
+ ready: function(callback) {
+ return callback.call(this);
+ },
reload: function() {
var data, param, params, promise, _i, _len;
params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
data = params.pop();
@@ -20890,18 +20894,23 @@
params.push(data);
}
promise = rest.get.call(this, data || {});
promise.done(this.assign_attributes);
promise.fail(this.failed);
+ this.reloading = promise;
+ this.ready = function() {
+ console.warn("resource.ready was deprecated, please use resource.reloading.done");
+ return promise.done.apply(promise, arguments);
+ };
for (_i = 0, _len = params.length; _i < _len; _i++) {
param = params[_i];
promise.done(param);
}
return promise;
},
assign_attributes: function(attributes) {
- var association, association_attributes, association_name, associations_attributes, attribute, message, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
+ var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
_ref = model[this.resource.toString()].has_many;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
association_name = _ref[_i];
associations_attributes = attributes[association_name];
@@ -20942,13 +20951,22 @@
if (association_attributes) {
this[association_name] = this["build_" + association_name](association_attributes);
}
}
_results = [];
- for (attribute in attributes) {
- if (attribute !== this[attribute]) {
- _results.push(this[attribute] = attributes[attribute]);
+ for (name in attributes) {
+ attribute = attributes[name];
+ if (attribute !== this[name]) {
+ if (type(attribute) === 'object') {
+ if (JSON.stringify(attribute) !== JSON.stringify(this[name])) {
+ _results.push(this[name] = attributes[name]);
+ } else {
+ _results.push(void 0);
+ }
+ } else {
+ _results.push(this[name] = attributes[name]);
+ }
}
}
return _results;
},
destroy: function(doned, failed, data) {
@@ -20965,22 +20983,27 @@
return promise;
},
saving: false,
salvation: null,
save: function(doned, failed, data) {
- var salvation;
+ var lock, salvation;
+ lock = JSON.stringify(this.json());
if (this.saving) {
- return this.salvation;
+ if (this.lock === lock) {
+ return this.salvation;
+ } else {
+ this.salvation.abort();
+ }
}
- this.lock = JSON.stringify(this.json());
+ this.lock = lock;
if (!this.dirty) {
salvation = $.Deferred().resolveWith(this, null);
}
+ this.saving = true;
salvation || (salvation = rest[this._id ? 'put' : 'post'].call(this, data));
this.salvation = salvation;
- this.saving = true;
salvation.done(this.saved);
salvation.fail(this.failed);
salvation.always(function() {
return this.saving = false;
});
@@ -20992,12 +21015,10 @@
var callback, _i, _len, _ref, _results;
if (this.lock === JSON.stringify(this.json())) {
this.dirty = false;
delete this.lock;
- } else {
- return this.save();
}
if (data != null) {
this.assign_attributes(data);
}
if (this.after_save) {
@@ -21019,12 +21040,25 @@
} catch (_error) {
e = _error;
}
payload || (payload = xhr.responseText);
switch (xhr.status) {
+ case 0:
+ message = status || xhr.statusText;
+ switch (message) {
+ case 'abort':
+ console.info("salvation probably aborted");
+ break;
+ case 'error':
+ console.info("server probably unreachable");
+ break;
+ default:
+ throw new Error('Unhandled status code for xhr');
+ }
+ break;
case 422:
- definition = model[this.resource];
+ definition = model[this.resource.toString()];
_ref = payload.errors;
for (attribute_name in _ref) {
messages = _ref[attribute_name];
if (!definition.associations) {
definition.associations = definition.has_one.concat(definition.has_many.concat(definition.belongs_to));
@@ -21045,12 +21079,13 @@
}
break;
default:
message = "Fail in " + this.resource + ".save:\n";
message += "Record: " + this + "\n";
- message += "Status: " + status + " (" + (payload.status || xhr.status) + ")\n";
+ message += "Status: " + status + " (" + (payload || xhr).status + ")\n";
message += "Error : " + (payload.error || payload.message || payload);
+ console.log(message);
}
return this.saving = false;
},
toString: function() {
var serialized;
@@ -21058,24 +21093,31 @@
serialized = {};
serialized[this.resource] = this.json();
return JSON.stringify(serialized);
},
json: function(methods) {
- var attribute, json, name, value, _i, _len, _ref;
+ var attribute, definition, json, name, value, _i, _len, _ref;
if (methods == null) {
methods = {};
}
json = {};
+ definition = model[this.resource.toString()];
for (name in this) {
- value = this[name];
- if (!(type(value) !== 'function')) {
+ if (!(type(value))) {
continue;
}
+ if (definition.belongs_to.indexOf(name) !== -1 && this.nested_attributes.indexOf(name) === -1) {
+ continue;
+ }
+ value = this[name];
if (value == null) {
continue;
}
+ if (type(value) === 'function') {
+ continue;
+ }
if (type(value) === 'object') {
if (value.toJSON != null) {
json[name] = value.toJSON(methods[name]);
} else {
_ref = this.nested_attributes;
@@ -21097,10 +21139,12 @@
delete json.initial_route;
delete json.after_initialize;
delete json.before_initialize;
delete json.parent_resource;
delete json.nested_attributes;
+ delete json.reloading;
+ delete json.ready;
delete json.saving;
delete json.salvation;
delete json.sustained;
delete json.element;
delete json["default"];
@@ -21143,27 +21187,44 @@
};
});
});
require.register("indemma/lib/record/scopable.js", function(exports, require, module){
-var $, builders, defaults, extend, merge, model, record, rest, scopable, stampit,
+var $, builders, defaults, extend, merge, model, observable, record, rest, scopable, stampit, util,
__slice = [].slice;
require('./restfulable');
require('./resource');
stampit = require('../../vendor/stampit');
extend = require('assimilate');
+observable = require('observable').mixin;
+
merge = extend.withStrategy('deep');
$ = require('jquery');
rest = require('./rest');
+util = {
+ model: {
+ map: function(records) {
+ var index, record, _i, _len, _results;
+
+ _results = [];
+ for (index = _i = 0, _len = records.length; _i < _len; index = ++_i) {
+ record = records[index];
+ _results.push((this.build || this).call(this, record));
+ }
+ return _results;
+ }
+ }
+};
+
scopable = {
builder: stampit().enclose(function() {
return stampit.mixIn(function(name, type) {
var builder;
@@ -21190,18 +21251,23 @@
fail: [],
declared: [],
fetch: function(data, done, fail) {
var deferred, scope;
+ if (typeof data === 'function') {
+ done = data;
+ data = {};
+ }
scope = extend({}, this.scope.data);
+ observable.unobserve(scope);
if (scope.noned != null) {
deferred = $.Deferred();
deferred.resolveWith(this, [[]]);
} else {
deferred = rest.get.call(this, extend(scope, data));
}
- deferred.done(this.scope.then.concat(done)).fail([this.scope.fail, fail]);
+ deferred.then(util.model.map).done(this.scope.then.concat([done])).fail(this.scope.fail.concat([fail]));
this.scope.clear();
return deferred;
},
clear: function() {
this.data = {};
@@ -21240,10 +21306,14 @@
none: function() {
this.scope.data.noned = true;
return this;
},
fetch: function(data, done, fail) {
+ if (typeof data === 'function') {
+ done = data;
+ data = null;
+ }
return this.scope.fetch.call(this, data, done, fail);
},
forward_scopes_to_associations: function() {
var associated_factory, associated_resource, association, association_name, factory, forwarder, generate_forwarder, scope, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4;
@@ -21496,37 +21566,48 @@
model.mix(function(modelable) {
return extend(modelable, extensions.model);
});
});
-require.register("indemma/lib/record/validations/confirmation.js", function(exports, require, module){
-var composed, confirmationable, stampit, validations;
+require.register("indemma/lib/record/validations/validatorable.js", function(exports, require, module){
+var stampit;
-validations = require('../validatable');
+stampit = require('../../../vendor/stampit');
+module.exports = stampit({
+ validate: function() {
+ throw new Error('Composed factory must override the validate method');
+ },
+ validate_each: function() {
+ throw new Error('Composed factory must override the validate each method');
+ }
+});
+
+});
+require.register("indemma/lib/record/validations/confirmation.js", function(exports, require, module){
+var composed, confirmationable, stampit;
+
stampit = require('../../../vendor/stampit');
confirmationable = stampit({
validate_each: function(record, attribute, value) {
if (record[attribute] !== record["" + attribute + "_confirmation"]) {
return record.errors.add("" + attribute + "_confirmation", 'confirmation', this.options);
}
}
});
-composed = stampit.compose(validations.validatable, confirmationable);
+composed = stampit.compose(require('./validatorable'), confirmationable);
composed.definition_key = 'validates_confirmation_of';
-validations.manager.validators.confirmation = composed;
+module.exports = composed;
});
require.register("indemma/lib/record/validations/associated.js", function(exports, require, module){
-var associationable, composed, stampit, validations;
+var associationable, composed, stampit;
-validations = require('../validatable');
-
stampit = require('../../../vendor/stampit');
associationable = stampit({
validate_each: function(record, attribute, value) {
var associated_validation;
@@ -21544,46 +21625,40 @@
return associated_validation;
}
}
});
-composed = stampit.compose(validations.validatable, associationable);
+composed = stampit.compose(require('./validatorable'), associationable);
composed.definition_key = 'validates_associated';
-validations.manager.validators.association = composed;
+module.exports = composed;
});
require.register("indemma/lib/record/validations/presence.js", function(exports, require, module){
-var composed, presenceable, stampit, validations;
+var composed, presenceable, stampit;
-validations = require('../validatable');
-
stampit = require('../../../vendor/stampit');
presenceable = stampit({
validate_each: function(record, attribute, value) {
if (value === null || value === '' || value === void 0) {
return record.errors.add(attribute, 'blank', this.options);
}
}
});
-composed = stampit.compose(validations.validatable, presenceable);
+composed = stampit.compose(require('./validatorable'), presenceable);
composed.definition_key = 'validates_presence_of';
-validations.manager.validators.presence = composed;
+module.exports = composed;
});
require.register("indemma/lib/record/validations/remote.js", function(exports, require, module){
-var composed, remoteable, rest, root, stampit, validations;
+var composed, remoteable, rest, stampit;
-root = typeof exports !== "undefined" && exports !== null ? exports : window;
-
-validations = require('../validatable');
-
rest = require('../rest');
stampit = require('../../../vendor/stampit');
remoteable = stampit({
@@ -21641,15 +21716,15 @@
this.resource = this.model.resource;
this.route || (this.route = "/" + pluralized_resource + "/validate");
return this;
});
-composed = stampit.compose(validations.validatable, remoteable);
+composed = stampit.compose(require('./validatorable'), remoteable);
composed.definition_key = 'validates_remotely';
-validations.manager.validators.remote = composed;
+module.exports = composed;
});
require.register("indemma/lib/record/validations/type.js", function(exports, require, module){
var composed, stampit, typeable, validations;
@@ -21673,22 +21748,20 @@
}
}
}
});
-composed = stampit.compose(validations.validatable, typeable);
+composed = stampit.compose(require('./validatorable'), typeable);
composed.definition_key = 'validates_type_of';
-validations.manager.validators.type = composed;
+module.exports = composed;
});
require.register("indemma/lib/record/validations/cpf.js", function(exports, require, module){
-var composed, cpfable, stampit, validations;
+var composed, cpfable, stampit;
-validations = require('../validatable');
-
stampit = require('../../../vendor/stampit');
cpfable = stampit({
validate_format: function(value) {
var c, d1, dv, i, v, _i, _j;
@@ -21703,11 +21776,11 @@
c = value.substr(0, 9);
dv = value.substr(9, 2);
d1 = 0;
v = false;
i = 0;
- for (i = _i = 1; _i <= 9; i = ++_i) {
+ for (i = _i = 0; _i <= 9; i = ++_i) {
d1 += c.charAt(i) * (10 - i);
}
if (d1 === 0) {
return false;
}
@@ -21717,11 +21790,11 @@
}
if (+dv.charAt(0) !== d1) {
return false;
}
d1 *= 2;
- for (i = _j = 1; _j <= 9; i = ++_j) {
+ for (i = _j = 0; _j <= 9; i = ++_j) {
d1 += c.charAt(i) * (11 - i);
}
d1 = 11 - (d1 % 11);
if (d1 > 9) {
d1 = 0;
@@ -21736,23 +21809,23 @@
return record.errors.add(attribute, 'cpf', this.options);
}
}
});
-composed = stampit.compose(validations.validatable, cpfable);
+composed = stampit.compose(require('./validatorable'), cpfable);
composed.definition_key = 'validates_cpf_format';
-validations.manager.validators.cpf = composed;
+module.exports = composed;
});
require.register("indemma/lib/record/validatable.js", function(exports, require, module){
-var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type, validatable;
+var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
require('./translationable');
-root = typeof exports !== "undefined" && exports !== null ? exports : window;
+root = typeof exports !== "undefined" && exports !== null ? exports : this;
stampit = require('../../vendor/stampit');
observable = require('observable').mixin;
@@ -21839,11 +21912,11 @@
return this.validate();
}
});
this.validated = false;
this.subscribe('dirty', function(value) {
- return this.validated = false;
+ return value && (this.validated = false);
});
return Object.defineProperty(this, 'valid', {
get: function() {
this.validate();
if (this.validation.state() === 'resolved') {
@@ -21933,52 +22006,44 @@
}
this.validation = jQuery.when.apply(jQuery, results);
this.validation.done(doned);
this.validation.fail(failed);
this.validation.then(function(record) {
- return record.validated = true;
+ var old_dirty;
+
+ old_dirty = record.dirty;
+ record.dirty = null;
+ record.validated || (record.validated = true);
+ return record.dirty = old_dirty;
});
return this.validation;
}
}
};
manager = {
validators: {}
};
-validatable = stampit({
- validate: function() {
- throw new Error('Composed factory must override the validate method');
- },
- validate_each: function() {
- throw new Error('Composed factory must override the validate each method');
- }
-});
-
model.mix(function(modelable) {
jQuery.extend(modelable, extensions.model);
jQuery.extend(modelable.record, extensions.record);
modelable.after_mix.unshift(initializers.create_validators);
modelable.record.after_initialize.push(initializers.define_triggers);
return model.validators = manager.validators;
});
-root.validatable = validatable;
+manager.validators.confirmation = require('./validations/confirmation');
-root.manager = manager;
+manager.validators.associated = require('./validations/associated');
-require('./validations/confirmation');
+manager.validators.presence = require('./validations/presence');
-require('./validations/associated');
+manager.validators.remote = require('./validations/remote');
-require('./validations/presence');
+manager.validators.type = require('./validations/type');
-require('./validations/remote');
-
-require('./validations/type');
-
-require('./validations/cpf');
+manager.validators.cpf = require('./validations/cpf');
});
require.register("indemma/lib/extensions/rivets.js", function(exports, require, module){
var root;