0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/shared/models/dataProvider.json.js
Jacob Gable a8bf3c962f Ghost.init()
- Modified jsonDataProvider to return promises for findAll and save
- Move the dataProvider initialization into the Ghost.init() function.
- Created basic unit test
2013-05-30 23:39:02 +01:00

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;
}());