Sha256: 767c9a94532bfb7ca64d5776e4337854b7e817436671f8b7a41e60d9c43e674d
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
# ------------------------------------------------------------------ # # The ModelChangeMonitor watches for changes on the # # Model and remembers which attributes have been changed # # ------------------------------------------------------------------ # class Lanes.Models.ChangeMonitor constructor: (model)-> model.on('change', this.onChange, this) model.on('change:isDirty', this.onDirtyChange, this) onChange: (record,options)-> attrs = record.changedAttributes() return if _.isEmpty(attrs) @_unsaved ||= {} this.recordChanges(record,_.keys(attrs)) recordChanges: (record,names) -> for name in names if name != record.idAttribute && record._definition[name] && !record._definition[name].session record.isDirty = true @_unsaved[ name ] = true onDirtyChange: (record,isDirty)-> delete @_unsaved if !isDirty changedAttributes: -> _.keys(@_unsaved) isDirty: -> !_.isEmpty(@_unsaved)
Version data entries
4 entries across 4 versions & 1 rubygems