0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Removes objectTypeModelMap to reduce circular dependency.

refs #2455

- also note areas where we still have lazy loading of modules.
- moves one lazy loading to non-lazy require.
This commit is contained in:
Harry Wolff 2014-09-21 16:54:32 -04:00
parent f6eccf4bd1
commit 6cbcfac72b
4 changed files with 9 additions and 12 deletions

View file

@ -5,6 +5,7 @@ var _ = require('lodash'),
config = require('../config'),
canThis = require('../permissions').canThis,
errors = require('../errors'),
mailer = require('../mail'),
Models = require('../models'),
path = require('path'),
fs = require('fs'),
@ -29,8 +30,6 @@ mail = {
* @returns {Promise}
*/
send: function (object, options) {
var mailer = require('../mail');
return canThis(options.context).send.mail().then(function () {
return mailer.send(object.mail[0].message)
.then(function (data) {

View file

@ -24,7 +24,7 @@ var _ = require('lodash'),
colors.setTheme({silly: 'rainbow'});
// Shim right now to deal with circular dependencies.
// @TODO: remove circular dependency
// @TODO(hswolff): remove circular dependency and lazy require.
function getConfigModule() {
if (!config) {
config = require('../config');

View file

@ -50,8 +50,13 @@ CanThisResult = function () {
};
CanThisResult.prototype.buildObjectTypeHandlers = function (objTypes, actType, context, permissionLoad) {
// @TODO: remove this lazy require
var objectTypeModelMap = require('./object-type-model-map');
var objectTypeModelMap = {
post: Models.Post,
role: Models.Role,
user: Models.User,
permission: Models.Permission,
setting: Models.Settings
};
// Iterate through the object types, i.e. ['post', 'tag', 'user']
return _.reduce(objTypes, function (objTypeHandlers, objType) {

View file

@ -1,7 +0,0 @@
module.exports = {
post: require('../models/post').Post,
role: require('../models/role').Role,
user: require('../models/user').User,
permission: require('../models/permission').Permission,
setting: require('../models/settings').Settings
};