Serializer: add generic seriealize and deserliealize methods

This commit is contained in:
ac360 2016-02-18 09:06:53 -08:00
parent a5bba02861
commit ec184b600f
13 changed files with 25 additions and 7 deletions

View File

@ -24,6 +24,7 @@ class ServerlessComponent extends SerializerFileSystem {
let _this = this;
_this._S = Serverless;
_this._class = 'Component';
_this._config = {};
_this._project = project;
_this.updateConfig(config);

View File

@ -28,6 +28,7 @@ class Endpoint extends SerializerFileSystem {
// Private properties
let _this = this;
_this._S = Serverless;
_this._class = 'Endpoint';
_this._function = func;
_this.updateConfig(config);

View File

@ -28,6 +28,7 @@ class Event extends SerializerFileSystem {
// Private properties
let _this = this;
_this._S = Serverless;
_this._class = 'Error';
_this._config = {};
_this._function = func;

View File

@ -25,6 +25,7 @@ class Function extends SerializerFileSystem {
let _this = this;
_this._S = Serverless;
_this._class = 'Function';
_this._config = {};
_this._component = component;

View File

@ -18,7 +18,8 @@ class ServerlessPlugin {
*/
constructor(S) {
this.S = S;
this.S = S;
this._class = 'Plugin';
}
/**

View File

@ -26,6 +26,7 @@ class Project extends SerializerFileSystem {
let _this = this;
_this._S = S;
_this._class = 'Project';
// Default properties
_this.name = 'serverless' + SUtils.generateShortId(6);
@ -49,7 +50,7 @@ class Project extends SerializerFileSystem {
*/
load() {
return this.deserializeProject(this);
return this.deserialize(this);
}
/**
@ -58,7 +59,7 @@ class Project extends SerializerFileSystem {
*/
save(options) {
return this.serializeProject(this, options);
return this.serialize(this, options);
}
/**

View File

@ -10,6 +10,7 @@ class Region extends SerializerFileSystem {
super();
this._S = S;
this._class = 'Region';
this._stage = stage;
this._variables = new this._S.classes.Variables();

View File

@ -11,6 +11,7 @@ class Resources {
constructor(S, config) {
this._S = S;
this._class = 'Resources';
this._config = config;
this._modules = [];
}

View File

@ -12,8 +12,8 @@ const SError = require('./Error'),
class ServerlessRuntimeBase {
constructor(S, name) {
this.S = S;
this.name = name;
this.S = S;
this.name = name;
}
populateComponentFolder( componentPath ) {

View File

@ -19,6 +19,14 @@ class SerializerFileSystem {
this._projectPath = S.config.serializer.projectPath;
}
serialize(asset) {
return this['serialize' + asset._class].apply(_.toArray(arguments));
}
deserialize(asset) {
return this['deserialize' + asset._class].apply(_.toArray(arguments));
}
/**
* Deserialize Project
*/

View File

@ -11,6 +11,7 @@ class Stage extends SerializerFileSystem {
super();
this._S = S;
this._class = 'Stage';
this._project = project;
this._regions = {};
this._variables = new this._S.classes.Variables(this._S);

View File

@ -10,6 +10,7 @@ class Templates {
constructor(S, config) {
this._S = S;
this._class = 'Templates';
this._config = config;
}
}

View File

@ -11,8 +11,8 @@ class Variables extends SerializerFileSystem {
constructor(S) {
super();
this._S = S;
this._S = S;
this._class = 'Variables';
}
load() {