basic get&set of Map properties works

This commit is contained in:
Kevin Jahns
2015-06-29 13:20:19 +02:00
parent 8f63147dbc
commit bffbb6ca27
14 changed files with 146 additions and 56 deletions

29
src/Types/Map.js Normal file
View File

@@ -0,0 +1,29 @@
(function(){
class Map {
constructor (_model) {
this._model = _model;
}
*val () {
var transaction = yield "transaction";
var model = yield* transaction.getOperation(this._model);
if (arguments.length === 0) {
throw new Error("Implement this case!");
} else if (arguments.length === 1) {
return yield* Y.Struct.Map.get.call(transaction, model, arguments[0]);
} else {
return yield* Y.Struct.Map.set.call(transaction, model, arguments[0], arguments[1]);
}
}
}
Y.Map = function* YMap(){
if (this instanceof Y.AbstractOperationStore) {
var model = yield* Y.Struct.map.create.call(this);
return new Map(model);
} else {
throw new Error("Don't use `new` to create this type!");
}
};
Y.Map.Create = Map;
})();

View File

@@ -1,25 +0,0 @@
(function(){
class Map {
constructor (_model) {
this._model = _model;
}
*val () {
var transaction = yield "transaction";
var model = transaction.getOperation(this._model);
if (arguments.length === 0) {
throw new Error("Implement this case!");
} else if (arguments.length === 1) {
return yield* this.Struct.Map.get.call(transaction, model, arguments[0]);
} else {
return yield* this.Struct.Map.set.call(transaction, model, arguments[0], arguments[1]);
}
}
}
Y.Map = function* YMap(){
var model = yield* this.Struct.map.create.call(this);
return new Map(model);
};
Y.Map.Create = Map;
})();