mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
- Modified jsonDataProvider to return promises for findAll and save - Move the dataProvider initialization into the Ghost.init() function. - Created basic unit test
35 lines
No EOL
887 B
JavaScript
35 lines
No EOL
887 B
JavaScript
/**
|
|
* Dummy dataProvider returns hardcoded JSON data until we finish migrating settings data to a datastore
|
|
*/
|
|
|
|
/*globals module, require */
|
|
(function () {
|
|
"use strict";
|
|
|
|
var _ = require('underscore'),
|
|
when = require('when'),
|
|
DataProvider,
|
|
instance;
|
|
|
|
DataProvider = function () {
|
|
if (!instance) {
|
|
instance = this;
|
|
_.extend(instance, {
|
|
data: [],
|
|
findAll: function() {
|
|
return when(instance.data);
|
|
},
|
|
save: function (globals) {
|
|
_.each(globals, function (global, key) {
|
|
instance.data[key] = global;
|
|
}, instance);
|
|
|
|
return when(globals);
|
|
}
|
|
});
|
|
}
|
|
return instance;
|
|
};
|
|
|
|
module.exports = DataProvider;
|
|
}()); |