ende 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f449455409778c5c3e5ec35ddca98f3339697aeb
4
- data.tar.gz: 1003d18179ca52da6a126802fac9077558124031
3
+ metadata.gz: b0e48bf4ef7898c1ec8445c6cc33851d80d7faef
4
+ data.tar.gz: 3cea46379431f55fc0890ea0ed4ae1114e8c4074
5
5
  SHA512:
6
- metadata.gz: f1f5145003bcd0c7312d9ca396d96836dba90f9d50b776b72fb3a72f5c7c9bfe43103d6e99208140d76bbfe60d200f14b7d0794a95f392c6e9628c6a1c4ab099
7
- data.tar.gz: d8caf05992ebc99554db35804cbf5db628be84c5271ccf7a9593144bcfe2d1e013272547e64200c426e82d205777cf67fc8a521557083367554875ab96f01b29
6
+ metadata.gz: 4dd17eae28952f0f8bbd7a90ebb5100aeb4b406642709ff7a7c4cef1e5846da10804f864ba901058a3c9495d5cc530fbbfe45b28c59d2c0f140b32bd117c5fd4
7
+ data.tar.gz: a39c1a3f4d6cad47b5b88ded0fecd7a458b6ee33633532e5cc405dd7ff4758b16f1dc3c4a17d195a94bfd0ca102db617a1ffa9847253dfc2f2ea47bbbc05693f
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "indemma",
3
3
  "description": "Indemma (mind picture = memory), client side ES5 observable REST model",
4
- "version": "0.1.13",
4
+ "version": "0.1.14",
5
5
  "keywords": [],
6
6
  "dependencies": {
7
7
  "pluma/assimilate": "0.3.0",
@@ -332,7 +332,8 @@ associable = {
332
332
  old_resource = this[resource];
333
333
  Object.defineProperty(record, resource.toString(), {
334
334
  get: $.proxy(descriptors.belongs_to.resource.getter, association_proxy),
335
- set: $.proxy(descriptors.belongs_to.resource.setter, association_proxy)
335
+ set: $.proxy(descriptors.belongs_to.resource.setter, association_proxy),
336
+ configurable: true
336
337
  });
337
338
  _results.push(this[resource] = old_resource);
338
339
  }
@@ -11,7 +11,9 @@ dirtyable = {
11
11
  return this.observed.dirty;
12
12
  },
13
13
  set: function(value) {
14
- return this.observed.dirty = value;
14
+ this.observed.dirty = value;
15
+ this.observation.scheduler.schedule();
16
+ return value;
15
17
  }
16
18
  },
17
19
  record: {
@@ -147,7 +147,7 @@ restful = {
147
147
  return promise;
148
148
  },
149
149
  assign_attributes: function(attributes) {
150
- var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
150
+ var associated, association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
151
151
 
152
152
  _ref = model[this.resource.toString()].has_many;
153
153
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -189,7 +189,9 @@ restful = {
189
189
  delete attributes[association_name];
190
190
  delete attributes[association_name + "_attributes"];
191
191
  if (association_attributes) {
192
- this[association_name] = this["build_" + association_name](association_attributes);
192
+ associated = this[association_name] || this["build_" + association_name]();
193
+ associated.assign_attributes(association_attributes);
194
+ this[association_name] = associated;
193
195
  }
194
196
  }
195
197
  _ref3 = model[this.resource.toString()].belongs_to;
@@ -199,7 +201,9 @@ restful = {
199
201
  delete attributes[association_name];
200
202
  delete attributes[association_name + "_attributes"];
201
203
  if (association_attributes) {
202
- this[association_name] = this["build_" + association_name](association_attributes);
204
+ associated = this[association_name] || this["build_" + association_name]();
205
+ associated.assign_attributes(association_attributes);
206
+ this[association_name] = associated;
203
207
  }
204
208
  }
205
209
  _results = [];
@@ -92,6 +92,7 @@ initializers = {
92
92
  }
93
93
  });
94
94
  this.validated = false;
95
+ this.validation = null;
95
96
  this.subscribe('dirty', function(value) {
96
97
  return value && (this.validated = false);
97
98
  });
@@ -4,15 +4,16 @@ stampit = require('../../../vendor/stampit');
4
4
 
5
5
  associationable = stampit({
6
6
  validate_each: function(record, attribute, value) {
7
- var associated_validation;
7
+ var associated, associated_validation;
8
8
 
9
- if (record[attribute]) {
9
+ associated = record[attribute];
10
+ if (associated) {
10
11
  if (model[record.resource].has_one.indexOf(attribute) === -1) {
11
12
  throw new Error('Only has_one associations are supported to validates_associated');
12
13
  }
13
- associated_validation = record[attribute].validate();
14
+ associated_validation = associated.validate();
14
15
  associated_validation.done(function() {
15
- if (record[attribute].errors.length) {
16
+ if (associated.errors.length) {
16
17
  return record.errors.add(attribute, 'associated', this.options);
17
18
  }
18
19
  });
@@ -2,7 +2,7 @@
2
2
  "name": "observable",
3
3
  "repository": "indefinido/observable",
4
4
  "description": "Observable capabilities built upon observable shim.",
5
- "version": "0.2.1",
5
+ "version": "0.2.2",
6
6
  "keywords": [],
7
7
  "dependencies": {
8
8
  "component/jquery": "*"
@@ -1,4 +1,6 @@
1
- exports.adapter = {
1
+ var adapter;
2
+
3
+ adapter = {
2
4
  subscribe: function(record, attribute_path, callback) {
3
5
  if (record == null) {
4
6
  throw new TypeError('observable.adapters.rivets.subscribe: No record provided for subscription');
@@ -17,12 +19,22 @@ exports.adapter = {
17
19
  if (record == null) {
18
20
  throw new TypeError('observable.adapters.rivets.read: No record provided for subscription');
19
21
  }
20
- return record[attribute_path];
22
+ if (attribute_path.indexOf('.') === -1) {
23
+ return record[attribute_path];
24
+ } else {
25
+ return record.observation.observers[attribute_path].value_;
26
+ }
21
27
  },
22
28
  publish: function(record, attribute_path, value) {
23
29
  if (record == null) {
24
30
  throw new TypeError('observable.adapters.rivets.publish: No record provided for subscription');
25
31
  }
26
- return record[attribute_path] = value;
32
+ if (attribute_path.indexOf('.') === -1) {
33
+ return record[attribute_path] = value;
34
+ } else {
35
+ return record.observation.observers[attribute_path].setValue(value);
36
+ }
27
37
  }
28
38
  };
39
+
40
+ export default adapter;
@@ -16,7 +16,7 @@ scheduler = function(options) {
16
16
  };
17
17
  }
18
18
  jQuery.extend(options, {
19
- keypaths: {
19
+ schedulable_keypaths: {
20
20
  value: []
21
21
  },
22
22
  schedule: {
@@ -37,13 +37,13 @@ scheduler = function(options) {
37
37
 
38
38
  jQuery.extend(scheduler, {
39
39
  methods: {
40
- property: function(object, keypath) {
40
+ schedulable: function(object, keypath) {
41
41
  var observer, observers, value;
42
42
 
43
- if (this.keypaths.indexOf(keypath) !== -1) {
43
+ if (this.schedulable_keypaths.indexOf(keypath) !== -1) {
44
44
  return;
45
45
  }
46
- this.keypaths.push(keypath);
46
+ this.schedulable_keypaths.push(keypath);
47
47
  observers = object.observation.observers;
48
48
  observer = observers[keypath];
49
49
  value = observer.path_.getValueFrom(object);
@@ -54,7 +54,8 @@ jQuery.extend(scheduler, {
54
54
  configurable: true
55
55
  });
56
56
  if (value !== observer.path_.getValueFrom(object)) {
57
- return observer.setValue(value);
57
+ observer.setValue(value);
58
+ return object.observation.deliver();
58
59
  }
59
60
  },
60
61
  deliver: function() {
@@ -68,12 +69,14 @@ jQuery.extend(scheduler, {
68
69
  return function(value) {
69
70
  current_setter.call(this, value);
70
71
  this.observed[keypath] = value;
71
- return this.observation.scheduler.schedule();
72
+ this.observation.scheduler.schedule();
73
+ return value;
72
74
  };
73
75
  } else {
74
76
  return function(value) {
75
77
  this.observed[keypath] = value;
76
- return this.observation.scheduler.schedule();
78
+ this.observation.scheduler.schedule();
79
+ return value;
77
80
  };
78
81
  }
79
82
  },
@@ -91,13 +94,36 @@ jQuery.extend(scheduler, {
91
94
  });
92
95
 
93
96
  schedulerable = function(observable) {
97
+ schedulerable.storage_for(observable);
98
+ schedulerable.schedulable_observers();
99
+ return schedulerable.augment(observable);
100
+ };
101
+
102
+ schedulerable.storage_for = function(observable) {};
103
+
104
+ schedulerable.schedulable_observers = function() {
105
+ import {Path} from '../../vendor/observe-js/observe.js';
106
+ var original;
107
+
108
+ original = Path.prototype.setValueFrom;
109
+ return Path.prototype.setValueFrom = function(object) {
110
+ var changed;
111
+
112
+ changed = original.apply(this, arguments);
113
+ if (changed) {
114
+ return object.observation.scheduler.schedule();
115
+ }
116
+ };
117
+ };
118
+
119
+ schedulerable.augment = function(observable) {
94
120
  var original;
95
121
 
96
122
  original = observable.methods.subscribe;
97
123
  observable.methods.subscribe = function(keypath, callback) {
98
124
  original.apply(this, arguments);
99
125
  if (typeof keypath !== 'function') {
100
- return this.observation.scheduler.property(this, keypath);
126
+ return this.observation.scheduler.schedulable(this, keypath);
101
127
  }
102
128
  };
103
129
  return jQuery.extend((function() {
@@ -1,3 +1,4 @@
1
+
1
2
  'use strict';
2
3
 
3
4
  # TODO require formatters through aura instead of directly loding a module
@@ -10,15 +11,15 @@ define 'aura/extensions/rivets', ['aura/extensions/rivets/formatters'], (formatt
10
11
  Rivets = rivets._
11
12
 
12
13
  with_component = 'indefinido~observable@es6-modules/lib/adapters/rivets.js'
13
- observable_configuration = require with_component
14
+ observable_adapter = require with_component
14
15
 
15
16
  with_component = 'segmentio~extend@1.0.0'
16
17
  extend = require with_component
17
18
 
18
19
  extend rivets.formatters, formatters
19
20
 
20
- rivets.configure observable_configuration
21
21
  rivets.configure
22
+ adapter: observable_adapter
22
23
  prefix: ''
23
24
  templateDelimiters: ['{{', '}}']
24
25
 
data/lib/ende/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ende
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end