persistence draft

Persisting individual media file objects
This commit is contained in:
Cássio Zen
2016-06-06 21:53:22 -03:00
parent a0be4e0ae8
commit 83d03c63ec
10 changed files with 162 additions and 36 deletions

View File

@ -1,5 +1,6 @@
import yaml from 'js-yaml';
import moment from 'moment';
import ImageProxy from '../valueObjects/ImageProxy';
const MomentType = new yaml.Type('date', {
kind: 'scalar',
@ -14,9 +15,23 @@ const MomentType = new yaml.Type('date', {
}
});
const ImageType = new yaml.Type('image', {
kind: 'scalar',
instanceOf: ImageProxy,
represent: function(value) {
return `${value.uri}`;
},
resolve: function(value) {
if (value === null) return false;
if (value instanceof ImageProxy) return true;
return false;
}
});
const OutputSchema = new yaml.Schema({
include: yaml.DEFAULT_SAFE_SCHEMA.include,
implicit: [MomentType].concat(yaml.DEFAULT_SAFE_SCHEMA.implicit),
implicit: [MomentType, ImageType].concat(yaml.DEFAULT_SAFE_SCHEMA.implicit),
explicit: yaml.DEFAULT_SAFE_SCHEMA.explicit
});