ende 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/component.json +1 -1
  3. data/lib/assets/javascripts/aura/extensions/devise.js.coffee +7 -4
  4. data/lib/assets/javascripts/aura/extensions/routes.js.coffee +16 -8
  5. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +10 -5
  6. data/lib/assets/javascripts/widgets/authenticator/main.js.coffee +4 -8
  7. data/lib/assets/javascripts/widgets/authenticator/presenter.js.coffee +4 -4
  8. data/lib/assets/javascripts/widgets/authenticator/states/default.html +1 -1
  9. data/lib/assets/javascripts/widgets/tray/main.js.coffee +26 -0
  10. data/lib/ende/version.rb +1 -1
  11. data/lib/tasks/component.thor +1 -1
  12. data/vendor/assets/javascripts/ende/build.js +10008 -8202
  13. data/vendor/components/KapIT-observe-utils/component.json +16 -0
  14. data/vendor/components/KapIT-observe-utils/lib/observe-utils.js +780 -0
  15. data/vendor/components/chaijs-assertion-error/component.json +18 -0
  16. data/vendor/components/chaijs-assertion-error/index.js +110 -0
  17. data/vendor/components/chaijs-chai/component.json +47 -0
  18. data/vendor/components/chaijs-chai/index.js +1 -0
  19. data/vendor/components/chaijs-chai/lib/chai/assertion.js +130 -0
  20. data/vendor/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
  21. data/vendor/components/chaijs-chai/lib/chai/interface/assert.js +1080 -0
  22. data/vendor/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
  23. data/vendor/components/chaijs-chai/lib/chai/interface/should.js +76 -0
  24. data/vendor/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
  25. data/vendor/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
  26. data/vendor/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
  27. data/vendor/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
  28. data/vendor/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
  29. data/vendor/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
  30. data/vendor/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
  31. data/vendor/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
  32. data/vendor/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
  33. data/vendor/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
  34. data/vendor/components/chaijs-chai/lib/chai/utils/index.js +108 -0
  35. data/vendor/components/chaijs-chai/lib/chai/utils/inspect.js +320 -0
  36. data/vendor/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
  37. data/vendor/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
  38. data/vendor/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
  39. data/vendor/components/chaijs-chai/lib/chai/utils/test.js +26 -0
  40. data/vendor/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
  41. data/vendor/components/chaijs-chai/lib/chai/utils/type.js +45 -0
  42. data/vendor/components/chaijs-chai/lib/chai.js +80 -0
  43. data/vendor/components/chaijs-deep-eql/component.json +18 -0
  44. data/vendor/components/chaijs-deep-eql/lib/eql.js +257 -0
  45. data/vendor/components/chaijs-type-detect/component.json +16 -0
  46. data/vendor/components/chaijs-type-detect/lib/type.js +142 -0
  47. data/vendor/components/component-bind/component.json +14 -0
  48. data/vendor/components/component-bind/index.js +24 -0
  49. data/vendor/components/component-delegate/component.json +19 -0
  50. data/vendor/components/component-delegate/index.js +42 -0
  51. data/vendor/components/component-event/component.json +13 -0
  52. data/vendor/components/component-event/index.js +40 -0
  53. data/vendor/components/component-jquery/component.json +14 -0
  54. data/vendor/components/component-jquery/index.js +9601 -0
  55. data/vendor/components/component-link-delegate/component.json +23 -0
  56. data/vendor/components/component-link-delegate/index.js +60 -0
  57. data/vendor/components/component-matches-selector/component.json +20 -0
  58. data/vendor/components/component-matches-selector/index.js +45 -0
  59. data/vendor/components/component-query/component.json +21 -0
  60. data/vendor/components/component-query/index.js +21 -0
  61. data/vendor/components/component-type/component.json +18 -0
  62. data/vendor/components/component-type/index.js +32 -0
  63. data/vendor/components/component-url/component.json +17 -0
  64. data/vendor/components/component-url/index.js +63 -0
  65. data/vendor/components/components-modernizr/component.json +18 -0
  66. data/vendor/components/components-modernizr/modernizr.js +1393 -0
  67. data/vendor/components/discore-closest/component.json +14 -0
  68. data/vendor/components/discore-closest/index.js +18 -0
  69. data/vendor/components/indefinido-advisable/component.json +21 -0
  70. data/vendor/components/indefinido-advisable/index.js +1 -0
  71. data/vendor/components/indefinido-advisable/lib/advisable.js +60 -0
  72. data/vendor/components/indefinido-indemma/component.json +40 -0
  73. data/vendor/components/indefinido-indemma/index.js +1 -0
  74. data/vendor/components/indefinido-indemma/lib/extensions/rivets.js +23 -0
  75. data/vendor/components/indefinido-indemma/lib/record/associable.js +217 -0
  76. data/vendor/components/indefinido-indemma/lib/record/maid.js +24 -0
  77. data/vendor/components/indefinido-indemma/lib/record/resource.js +104 -0
  78. data/vendor/components/indefinido-indemma/lib/record/rest.js +36 -0
  79. data/vendor/components/indefinido-indemma/lib/record/restfulable.js +326 -0
  80. data/vendor/components/indefinido-indemma/lib/record/scopable.js +279 -0
  81. data/vendor/components/indefinido-indemma/lib/record/translationable.js +19 -0
  82. data/vendor/components/indefinido-indemma/lib/record/validatable.js +216 -0
  83. data/vendor/components/indefinido-indemma/lib/record/validations/associated.js +30 -0
  84. data/vendor/components/indefinido-indemma/lib/record/validations/confirmation.js +19 -0
  85. data/vendor/components/indefinido-indemma/lib/record/validations/cpf.js +60 -0
  86. data/vendor/components/indefinido-indemma/lib/record/validations/presence.js +19 -0
  87. data/vendor/components/indefinido-indemma/lib/record/validations/remote.js +71 -0
  88. data/vendor/components/indefinido-indemma/lib/record.js +167 -0
  89. data/vendor/components/indefinido-indemma/vendor/sinon.js +4290 -0
  90. data/vendor/components/indefinido-indemma/vendor/stampit.js +392 -0
  91. data/vendor/components/indefinido-observable/component.json +25 -0
  92. data/vendor/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
  93. data/vendor/components/indefinido-observable/index.js +1 -0
  94. data/vendor/components/indefinido-observable/lib/adapters/rivets.js +26 -0
  95. data/vendor/components/indefinido-observable/lib/observable.js +320 -0
  96. data/vendor/components/indefinido-observable/vendor/shims/accessors-legacy.js +92 -0
  97. data/vendor/components/indefinido-observable/vendor/shims/accessors.js +173 -0
  98. data/vendor/components/indefinido-observable/vendor/shims/array.indexOf.js +8 -0
  99. data/vendor/components/indefinido-observable/vendor/shims/object.create.js +77 -0
  100. data/vendor/components/mikeric-rivets/component.json +15 -0
  101. data/vendor/components/mikeric-rivets/dist/rivets.js +1239 -0
  102. data/vendor/components/paulmillr-es6-shim/component.json +17 -0
  103. data/vendor/components/paulmillr-es6-shim/es6-shim.js +985 -0
  104. data/vendor/components/pluma-assimilate/component.json +25 -0
  105. data/vendor/components/pluma-assimilate/dist/assimilate.js +87 -0
  106. data/vendor/components/segmentio-extend/component.json +13 -0
  107. data/vendor/components/segmentio-extend/index.js +15 -0
  108. metadata +98 -2
@@ -0,0 +1,216 @@
1
+ var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type, validatable;
2
+
3
+ require('./translationable');
4
+
5
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
6
+
7
+ stampit = require('../../vendor/stampit');
8
+
9
+ observable = require('observable').mixin;
10
+
11
+ type = require('type');
12
+
13
+ messages = {
14
+ blank: function(attribute_name) {
15
+ attribute_name = this.human_attribute_name(attribute_name);
16
+ return "O campo " + attribute_name + " não pode ficar em branco.";
17
+ },
18
+ cpf: function(attribute_name) {
19
+ attribute_name = this.human_attribute_name(attribute_name);
20
+ return "O campo " + attribute_name + " não está válido.";
21
+ },
22
+ confirmation: function(attribute_name) {
23
+ var confirmation_attribute_name;
24
+
25
+ confirmation_attribute_name = this.human_attribute_name("" + attribute_name + "_confirmation");
26
+ attribute_name = this.human_attribute_name(attribute_name);
27
+ return "O campo " + attribute_name + " não está diacordo com a confirmação " + confirmation_attribute_name + ".";
28
+ },
29
+ associated: function(attribute_name) {
30
+ attribute_name = this.human_attribute_name(attribute_name);
31
+ return "O registro associado " + attribute_name + " não é válido";
32
+ },
33
+ server: function(attribute_name, options) {
34
+ return "" + (this.human_attribute_name(attribute_name)) + " " + options.server_message + " ";
35
+ }
36
+ };
37
+
38
+ errorsable = stampit({
39
+ add: function(attribute_name, message_key, options) {
40
+ var translator;
41
+
42
+ this.push([attribute_name, message_key, options]);
43
+ this.messages[attribute_name] = '';
44
+ translator = messages[message_key];
45
+ if (translator != null) {
46
+ return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
47
+ } else {
48
+ return this.messages[attribute_name] += message_key;
49
+ }
50
+ },
51
+ clear: function() {
52
+ var attribute_name, _results;
53
+
54
+ if (this.length) {
55
+ this.length = 0;
56
+ _results = [];
57
+ for (attribute_name in this.messages) {
58
+ _results.push(this.messages[attribute_name] = null);
59
+ }
60
+ return _results;
61
+ }
62
+ },
63
+ push: Array.prototype.push,
64
+ splice: Array.prototype.splice
65
+ }, {
66
+ model: null,
67
+ messages: {},
68
+ length: 0
69
+ });
70
+
71
+ initializers = {
72
+ define_triggers: function() {
73
+ this.errors = errorsable({
74
+ model: model[this.resource]
75
+ });
76
+ this.before('save', function() {
77
+ if (this.save) {
78
+ return this.validate();
79
+ }
80
+ });
81
+ this.validated = false;
82
+ this.subscribe('dirty', function() {
83
+ return this.validated = false;
84
+ });
85
+ return Object.defineProperty(this, 'valid', {
86
+ get: function() {
87
+ this.validate();
88
+ if (this.validation.state() === 'resolved') {
89
+ return !this.errors.length;
90
+ } else {
91
+ return null;
92
+ }
93
+ },
94
+ set: function() {
95
+ throw new TypeError("You can't set the value for the valid property.");
96
+ },
97
+ enumerable: false
98
+ });
99
+ },
100
+ create_validators: function(definitions) {
101
+ var definition, name, validator, validator_options, _ref, _results;
102
+
103
+ _ref = manager.validators;
104
+ _results = [];
105
+ for (name in _ref) {
106
+ validator = _ref[name];
107
+ definition = definitions[validator.definition_key];
108
+ if (definition) {
109
+ if (type(definition) !== 'array') {
110
+ definition = [definition];
111
+ }
112
+ _results.push((function() {
113
+ var _i, _len, _results1;
114
+
115
+ _results1 = [];
116
+ for (_i = 0, _len = definition.length; _i < _len; _i++) {
117
+ validator_options = definition[_i];
118
+ if (type(validator_options) !== 'object') {
119
+ validator_options = {
120
+ attribute_name: validator_options
121
+ };
122
+ }
123
+ validator_options.model = this;
124
+ this.validators.push(validator(validator_options));
125
+ _results1.push(delete definitions[validator.definition_key]);
126
+ }
127
+ return _results1;
128
+ }).call(this));
129
+ } else {
130
+ _results.push(void 0);
131
+ }
132
+ }
133
+ return _results;
134
+ }
135
+ };
136
+
137
+ extensions = {
138
+ model: {
139
+ validators: []
140
+ },
141
+ record: {
142
+ validate_attribute: function(attribute, doned, failed) {
143
+ var results, validation, validator, _i, _len, _ref;
144
+
145
+ this.errors.messages[attribute] = null;
146
+ results = [this, attribute];
147
+ _ref = model[this.resource].validators;
148
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
149
+ validator = _ref[_i];
150
+ if (validator.attribute_name === attribute) {
151
+ results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
152
+ }
153
+ }
154
+ validation = jQuery.when.apply(jQuery, results);
155
+ validation.done(doned);
156
+ validation.fail(failed);
157
+ return validation;
158
+ },
159
+ validate: function(doned, failed) {
160
+ var results, validator, _i, _len, _ref;
161
+
162
+ if (this.validated) {
163
+ return this.validation;
164
+ }
165
+ this.errors.clear();
166
+ results = [this];
167
+ _ref = model[this.resource].validators;
168
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
169
+ validator = _ref[_i];
170
+ results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
171
+ }
172
+ this.validation = jQuery.when.apply(jQuery, results);
173
+ this.validation.done(doned);
174
+ this.validation.fail(failed);
175
+ this.validation.then(function(record) {
176
+ return record.validated = true;
177
+ });
178
+ return this.validation;
179
+ }
180
+ }
181
+ };
182
+
183
+ manager = {
184
+ validators: {}
185
+ };
186
+
187
+ validatable = stampit({
188
+ validate: function() {
189
+ throw new Error('Composed factory must override the validate method');
190
+ },
191
+ validate_each: function() {
192
+ throw new Error('Composed factory must override the validate each method');
193
+ }
194
+ });
195
+
196
+ model.mix(function(modelable) {
197
+ jQuery.extend(modelable, extensions.model);
198
+ jQuery.extend(modelable.record, extensions.record);
199
+ modelable.after_mix.unshift(initializers.create_validators);
200
+ modelable.record.after_initialize.push(initializers.define_triggers);
201
+ return model.validators = manager.validators;
202
+ });
203
+
204
+ root.validatable = validatable;
205
+
206
+ root.manager = manager;
207
+
208
+ require('./validations/confirmation');
209
+
210
+ require('./validations/associated');
211
+
212
+ require('./validations/presence');
213
+
214
+ require('./validations/remote');
215
+
216
+ require('./validations/cpf');
@@ -0,0 +1,30 @@
1
+ var associationable, composed, stampit, validations;
2
+
3
+ validations = require('../validatable');
4
+
5
+ stampit = require('../../../vendor/stampit');
6
+
7
+ associationable = stampit({
8
+ validate_each: function(record, attribute, value) {
9
+ var associated_validation;
10
+
11
+ if (record[attribute]) {
12
+ if (model[record.resource].has_one.indexOf(attribute) === -1) {
13
+ throw new Error('Only has_one associations are supported to validates_associated');
14
+ }
15
+ associated_validation = record[attribute].validate();
16
+ associated_validation.done(function() {
17
+ if (record[attribute].errors.length) {
18
+ return record.errors.add(attribute, 'associated', this.options);
19
+ }
20
+ });
21
+ return associated_validation;
22
+ }
23
+ }
24
+ });
25
+
26
+ composed = stampit.compose(validations.validatable, associationable);
27
+
28
+ composed.definition_key = 'validates_associated';
29
+
30
+ validations.manager.validators.association = composed;
@@ -0,0 +1,19 @@
1
+ var composed, confirmationable, stampit, validations;
2
+
3
+ validations = require('../validatable');
4
+
5
+ stampit = require('../../../vendor/stampit');
6
+
7
+ confirmationable = stampit({
8
+ validate_each: function(record, attribute, value) {
9
+ if (record[attribute] !== record["" + attribute + "_confirmation"]) {
10
+ return record.errors.add(attribute, 'confirmation', this.options);
11
+ }
12
+ }
13
+ });
14
+
15
+ composed = stampit.compose(validations.validatable, confirmationable);
16
+
17
+ composed.definition_key = 'validates_confirmation_of';
18
+
19
+ validations.manager.validators.confirmation = composed;
@@ -0,0 +1,60 @@
1
+ var composed, cpfable, stampit, validations;
2
+
3
+ validations = require('../validatable');
4
+
5
+ stampit = require('../../../vendor/stampit');
6
+
7
+ cpfable = stampit({
8
+ validate_format: function(value) {
9
+ var c, d1, dv, i, v, _i, _j;
10
+
11
+ value = value.replace(/[\.\-]/g, "");
12
+ if (value.length < 11) {
13
+ return false;
14
+ }
15
+ if (value.match(/^(0+|1+|2+|3+|4+|5+|6+|7+|8+|9+)$/)) {
16
+ return false;
17
+ }
18
+ c = value.substr(0, 9);
19
+ dv = value.substr(9, 2);
20
+ d1 = 0;
21
+ v = false;
22
+ i = 0;
23
+ for (i = _i = 1; _i <= 9; i = ++_i) {
24
+ d1 += c.charAt(i) * (10 - i);
25
+ }
26
+ if (d1 === 0) {
27
+ return false;
28
+ }
29
+ d1 = 11 - (d1 % 11);
30
+ if (d1 > 9) {
31
+ d1 = 0;
32
+ }
33
+ if (+dv.charAt(0 !== d1)) {
34
+ return false;
35
+ }
36
+ d1 *= 2;
37
+ for (i = _j = 1; _j <= 9; i = ++_j) {
38
+ d1 += c.charAt(i) * (11 - i);
39
+ }
40
+ d1 = 11 - (d1 % 11);
41
+ if (d1 > 9) {
42
+ d1 = 0;
43
+ }
44
+ if (+dv.charAt(1) !== d1) {
45
+ return false;
46
+ }
47
+ return true;
48
+ },
49
+ validate_each: function(record, attribute, value) {
50
+ if (value && !this.validate_format(value)) {
51
+ return record.errors.add(attribute, 'cpf', this.options);
52
+ }
53
+ }
54
+ });
55
+
56
+ composed = stampit.compose(validations.validatable, cpfable);
57
+
58
+ composed.definition_key = 'validates_cpf_format';
59
+
60
+ validations.manager.validators.cpf = composed;
@@ -0,0 +1,19 @@
1
+ var composed, presenceable, stampit, validations;
2
+
3
+ validations = require('../validatable');
4
+
5
+ stampit = require('../../../vendor/stampit');
6
+
7
+ presenceable = stampit({
8
+ validate_each: function(record, attribute, value) {
9
+ if (value === null || value === '' || value === void 0) {
10
+ return record.errors.add(attribute, 'blank', this.options);
11
+ }
12
+ }
13
+ });
14
+
15
+ composed = stampit.compose(validations.validatable, presenceable);
16
+
17
+ composed.definition_key = 'validates_presence_of';
18
+
19
+ validations.manager.validators.presence = composed;
@@ -0,0 +1,71 @@
1
+ var composed, remoteable, rest, root, stampit, validations;
2
+
3
+ root = typeof exports !== "undefined" && exports !== null ? exports : window;
4
+
5
+ validations = require('../validatable');
6
+
7
+ rest = require('../rest');
8
+
9
+ stampit = require('../../../vendor/stampit');
10
+
11
+ remoteable = stampit({
12
+ validate_each: function(record, attribute, value) {
13
+ var data,
14
+ _this = this;
15
+
16
+ data = this.json(record);
17
+ return this.post(data).done(function(json) {
18
+ return _this.succeeded(json, record);
19
+ });
20
+ },
21
+ json: function(record) {
22
+ var data, _base;
23
+
24
+ data = {};
25
+ data[this.resource] = record.json();
26
+ (_base = data[this.resource]).id || (_base.id = data[this.resource]._id);
27
+ delete data[this.resource]._id;
28
+ return data;
29
+ },
30
+ post: function(data) {
31
+ return jQuery.ajax({
32
+ url: this.route,
33
+ data: data,
34
+ type: 'post',
35
+ dataType: 'json',
36
+ context: this
37
+ });
38
+ },
39
+ succeeded: function(json, record) {
40
+ var error_message, error_messages, _i, _len, _results;
41
+
42
+ error_messages = json[this.attribute_name];
43
+ if (!error_messages) {
44
+ return;
45
+ }
46
+ _results = [];
47
+ for (_i = 0, _len = error_messages.length; _i < _len; _i++) {
48
+ error_message = error_messages[_i];
49
+ _results.push(record.errors.add(this.attribute_name, 'server', {
50
+ server_message: error_message
51
+ }));
52
+ }
53
+ return _results;
54
+ }
55
+ }, {
56
+ message: "Remote validation failed",
57
+ route: null
58
+ }, function() {
59
+ var pluralized_resource;
60
+
61
+ pluralized_resource = model.pluralize(this.model.resource);
62
+ this.resource = this.model.resource;
63
+ this.route || (this.route = "/" + pluralized_resource + "/validate");
64
+ return this;
65
+ });
66
+
67
+ composed = stampit.compose(validations.validatable, remoteable);
68
+
69
+ composed.definition_key = 'validates_remotely';
70
+
71
+ validations.manager.validators.remote = composed;
@@ -0,0 +1,167 @@
1
+ var $, advisable, bind, extend, merge, observable, type,
2
+ __slice = [].slice;
3
+
4
+ $ = require('jquery');
5
+
6
+ type = require('type');
7
+
8
+ bind = require('bind');
9
+
10
+ observable = require('observable').mixin;
11
+
12
+ advisable = require('advisable').mixin;
13
+
14
+ extend = require('assimilate');
15
+
16
+ merge = require('assimilate').withStrategy('deep');
17
+
18
+ this.model = (function() {
19
+ var initialize_record, mixer, modelable;
20
+
21
+ modelable = {
22
+ after_mix: [],
23
+ record: {
24
+ after_initialize: []
25
+ },
26
+ all: function() {
27
+ return this.cache;
28
+ },
29
+ create: function() {
30
+ var params;
31
+
32
+ params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
33
+ throw 'model.create not implemented yet, try using the restful.model.create method';
34
+ },
35
+ find: function(id) {
36
+ return this.where({
37
+ id: id
38
+ }, true);
39
+ },
40
+ where: function(conditions, first) {
41
+ var record, results, _i, _len, _ref;
42
+
43
+ if (first == null) {
44
+ first = false;
45
+ }
46
+ results = [];
47
+ if (type(conditions.id) !== 'array') {
48
+ conditions.id = [conditions.id];
49
+ }
50
+ _ref = this.cache;
51
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
52
+ record = _ref[_i];
53
+ if (conditions.id.indexOf(record._id) !== -1) {
54
+ if (first) {
55
+ return record;
56
+ } else {
57
+ results.push(record);
58
+ }
59
+ }
60
+ }
61
+ if (first) {
62
+ return null;
63
+ } else {
64
+ return results;
65
+ }
66
+ }
67
+ };
68
+ initialize_record = function(data) {
69
+ var after_initialize, callback, instance, _i, _len, _ref;
70
+
71
+ if (data == null) {
72
+ data = {
73
+ resource: this.resource,
74
+ parent_resource: this.parent_resource
75
+ };
76
+ }
77
+ data.resource || (data.resource = this.resource);
78
+ data.parent_resource || (data.parent_resource = this.resource.parent || this.parent_resource);
79
+ data.route || (data.route = this.route);
80
+ data.nested_attributes = this.nested_attributes || [];
81
+ after_initialize = (data.after_initialize || []).concat(this.record.after_initialize);
82
+ instance = record.call(extend(Object.create(data), this.record, {
83
+ after_initialize: after_initialize
84
+ }));
85
+ _ref = instance.after_initialize;
86
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
87
+ callback = _ref[_i];
88
+ callback.call(instance, instance);
89
+ }
90
+ delete instance.after_initialize;
91
+ return instance;
92
+ };
93
+ mixer = function(options) {
94
+ var after_initialize, callback, instance, _i, _len, _ref;
95
+
96
+ if (this === window) {
97
+ throw 'Model mixin called incorrectly call with model.call {} instead of model({})';
98
+ }
99
+ if (!mixer.stale) {
100
+ mixer.stale = true;
101
+ }
102
+ if (this.record && this.record.after_initialize) {
103
+ after_initialize = this.record.after_initialize.splice(0);
104
+ } else {
105
+ after_initialize = [];
106
+ }
107
+ instance = bind(this, initialize_record);
108
+ extend(instance, merge(this, modelable));
109
+ this.record = instance.record = merge({}, instance.record, modelable.record);
110
+ this.record.after_initialize = instance.record.after_initialize = instance.record.after_initialize.concat(after_initialize);
111
+ _ref = modelable.after_mix;
112
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
113
+ callback = _ref[_i];
114
+ callback.call(instance, instance);
115
+ }
116
+ return mixer[this.resource.name || this.resource.toString()] = instance;
117
+ };
118
+ mixer.mix = function(blender) {
119
+ if (this.stale) {
120
+ throw "Trying to change model mixin with " + object + " but model already used.\nCheck your configuration order";
121
+ }
122
+ return blender(modelable);
123
+ };
124
+ return mixer;
125
+ })();
126
+
127
+ this.record = (function() {
128
+ var callbacks, recordable, that;
129
+
130
+ callbacks = {
131
+ dirtify: function() {
132
+ return this.subscribe(function(prop, value, old) {
133
+ if (prop !== 'dirty' && !this.dirty && value !== old) {
134
+ console.groupCollapsed("◉ Property '" + prop + "' dirtied a " + this.resource);
135
+ console.log(old, "→", value);
136
+ console.log(this);
137
+ console.groupEnd();
138
+ return this.dirty = true;
139
+ }
140
+ });
141
+ }
142
+ };
143
+ recordable = {
144
+ dirty: false,
145
+ after_initialize: [callbacks.dirtify]
146
+ };
147
+ that = function(data) {
148
+ var after_initialize;
149
+
150
+ if (this === window) {
151
+ throw "Mixin called incorrectly, call mixin with call method: record.call(object, data)";
152
+ }
153
+ data || (data = {});
154
+ after_initialize = (this.after_initialize || []).concat(data.after_initialize || []).concat(recordable.after_initialize);
155
+ return advisable(observable(extend(this, recordable, data, {
156
+ after_initialize: after_initialize
157
+ })));
158
+ };
159
+ that.mix = function(blender) {
160
+ return blender(recordable);
161
+ };
162
+ return that;
163
+ })();
164
+
165
+ exports.record = this.record;
166
+
167
+ exports.model = this.model;