mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Serializer: add generic seriealize and deserliealize methods
This commit is contained in:
parent
a5bba02861
commit
ec184b600f
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -28,6 +28,7 @@ class Event extends SerializerFileSystem {
|
||||
// Private properties
|
||||
let _this = this;
|
||||
_this._S = Serverless;
|
||||
_this._class = 'Error';
|
||||
_this._config = {};
|
||||
_this._function = func;
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ class Function extends SerializerFileSystem {
|
||||
|
||||
let _this = this;
|
||||
_this._S = Serverless;
|
||||
_this._class = 'Function';
|
||||
_this._config = {};
|
||||
_this._component = component;
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ class ServerlessPlugin {
|
||||
*/
|
||||
|
||||
constructor(S) {
|
||||
this.S = S;
|
||||
this.S = S;
|
||||
this._class = 'Plugin';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ class Resources {
|
||||
|
||||
constructor(S, config) {
|
||||
this._S = S;
|
||||
this._class = 'Resources';
|
||||
this._config = config;
|
||||
this._modules = [];
|
||||
}
|
||||
|
||||
@ -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 ) {
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -10,6 +10,7 @@ class Templates {
|
||||
|
||||
constructor(S, config) {
|
||||
this._S = S;
|
||||
this._class = 'Templates';
|
||||
this._config = config;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@ class Variables extends SerializerFileSystem {
|
||||
|
||||
constructor(S) {
|
||||
super();
|
||||
|
||||
this._S = S;
|
||||
this._S = S;
|
||||
this._class = 'Variables';
|
||||
}
|
||||
|
||||
load() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user