app/assets/javascripts/spine.js in spine-rails-0.0.4 vs app/assets/javascripts/spine.js in spine-rails-0.0.5
- old
+ new
@@ -393,24 +393,20 @@
Model.prototype.eql = function(rec) {
var _ref, _ref2;
return rec && rec.constructor === this.constructor && (rec.id === this.id || (_ref = this.id, __indexOf.call(rec.ids, _ref) >= 0) || (_ref2 = rec.id, __indexOf.call(this.ids, _ref2) >= 0));
};
Model.prototype.save = function() {
- var error;
+ var error, record;
error = this.validate();
if (error) {
this.trigger('error', error);
return false;
}
this.trigger('beforeSave');
- if (this.newRecord) {
- this.create();
- } else {
- this.update();
- }
+ record = this.newRecord ? this.create() : this.update();
this.trigger('save');
- return this;
+ return record;
};
Model.prototype.updateAttribute = function(name, value) {
this[name] = value;
return this.save();
};
@@ -472,11 +468,12 @@
this.trigger('beforeUpdate');
records = this.constructor.records;
records[this.id].load(this.attributes());
clone = records[this.id].clone();
clone.trigger('update');
- return clone.trigger('change', 'update');
+ clone.trigger('change', 'update');
+ return clone;
};
Model.prototype.create = function() {
var clone, records;
this.trigger('beforeCreate');
if (!this.id) {
@@ -485,11 +482,12 @@
this.newRecord = false;
records = this.constructor.records;
records[this.id] = this.dup(false);
clone = records[this.id].clone();
clone.trigger('create');
- return clone.trigger('change', 'create');
+ clone.trigger('change', 'create');
+ return clone;
};
Model.prototype.bind = function(events, callback) {
var binder, unbinder;
this.constructor.bind(events, binder = __bind(function(record) {
if (record && this.eql(record)) {
@@ -682,10 +680,10 @@
};
Spine = this.Spine = {};
if (typeof module !== "undefined" && module !== null) {
module.exports = Spine;
}
- Spine.version = '1.0.0';
+ Spine.version = '1.0.3';
Spine.isArray = isArray;
Spine.isBlank = isBlank;
Spine.$ = $;
Spine.Events = Events;
Spine.Log = Log;