miolo-model 3.0.0-beta.169 → 3.0.0-beta.172

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miolo-model",
3
- "version": "3.0.0-beta.169",
3
+ "version": "3.0.0-beta.172",
4
4
  "description": "Data models for miolo world",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -6,6 +6,24 @@ export default (BaseClass = class {}) =>
6
6
 
7
7
  resetCache = this.reset_cache
8
8
 
9
+ get_from_cache(key) {
10
+ if (this.__cache__ === undefined) {
11
+ return undefined
12
+ }
13
+ return this.__cache__[key]
14
+ }
15
+
16
+ getFromCache = this.get_from_cache
17
+
18
+ set_to_cache(key, value) {
19
+ if (this.__cache__ === undefined) {
20
+ this.__cache__ = {}
21
+ }
22
+ this.__cache__[key] = value
23
+ }
24
+
25
+ setToCache = this.set_to_cache
26
+
9
27
  get_from_cache_or_make(cache_key, make_callback) {
10
28
  if (this.__cache__ === undefined) {
11
29
  this.__cache__ = {}
@@ -80,8 +80,9 @@ export default class MioloArray extends CacheMixin(Array) {
80
80
 
81
81
  removeByField = this.remove_by_field
82
82
 
83
- append(data) {
84
- const item = new this.itemClass(data)
83
+ push(data) {
84
+ const item =
85
+ data !== undefined && data instanceof this.itemClass ? data : new this.itemClass(data)
85
86
  this[this.length] = item
86
87
  return item
87
88
  }
@@ -5,6 +5,7 @@ export default class MioloModel extends CacheMixin() {
5
5
  constructor(data) {
6
6
  super()
7
7
  this.data = data
8
+ this.reset_cache()
8
9
  }
9
10
 
10
11
  _get(field, def) {