4
votes

is there a way to override an attribute setter in Ember Data 1.0.0? I would like to clean up data before any events are fired or computed properties updated.

At now I use the following method, but I don't like it, since I have to always remember to use dirtyPosition when setting a new value:

SampleApp.Line = DS.Model.extend({

  position: DS.attr("number"),

  dirtyPosition: function(key, value) {
    this.set("position", Math.max(0, value));
  }

});

It would be much nicer if I could somehow override the position property... But I can't find a way to do this.

1

1 Answers

0
votes

I would try overriding Ember.Object#set; Source is here.