Skip to content

Commit

Permalink
Misc refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbastian-trayio committed Jun 28, 2019
1 parent 6176319 commit b918c9b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/addMethod/globalize/afterFailure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var when = require('when');
var _ = require('lodash');

var localOnly = require('./localOnly');

module.exports = function (config, body, params, res) {
var threadneedle = this;
Expand All @@ -13,7 +14,7 @@ module.exports = function (config, body, params, res) {

// Run global promise first
.then(function () {
if (_.isFunction(threadneedle._globalOptions.afterFailure) && !require('./localOnly')(config, 'afterFailure')) {
if (_.isFunction(threadneedle._globalOptions.afterFailure) && !localOnly(config, 'afterFailure')) {
return when(threadneedle._globalOptions.afterFailure(body, params, res));
}
})
Expand Down
3 changes: 2 additions & 1 deletion lib/addMethod/globalize/afterHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var when = require('when');
var _ = require('lodash');

var localOnly = require('./localOnly');

module.exports = function (config, error, body, params, res) {
var threadneedle = this;
Expand All @@ -13,7 +14,7 @@ module.exports = function (config, error, body, params, res) {

// Run global promise first
.then(function () {
if (_.isFunction(threadneedle._globalOptions.afterHeaders) && !require('./localOnly')(config, 'afterHeaders')) {
if (_.isFunction(threadneedle._globalOptions.afterHeaders) && !localOnly(config, 'afterHeaders')) {
return when(threadneedle._globalOptions.afterHeaders(error, params, body, res));
}
})
Expand Down
3 changes: 2 additions & 1 deletion lib/addMethod/globalize/afterSuccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var when = require('when');
var _ = require('lodash');

var localOnly = require('./localOnly');

module.exports = function (config, body, params, res) {
var threadneedle = this;
Expand All @@ -13,7 +14,7 @@ module.exports = function (config, body, params, res) {

// Run global promise first
.then(function () {
if (_.isFunction(threadneedle._globalOptions.afterSuccess) && !require('./localOnly')(config, 'afterSuccess')) {
if (_.isFunction(threadneedle._globalOptions.afterSuccess) && !localOnly(config, 'afterSuccess')) {
return when(threadneedle._globalOptions.afterSuccess(body, params, res));
}
})
Expand Down
3 changes: 2 additions & 1 deletion lib/addMethod/globalize/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
var when = require('when');
var _ = require('lodash');

var localOnly = require('./localOnly');

module.exports = function (config, params) {
var threadneedle = this;
Expand All @@ -17,7 +18,7 @@ module.exports = function (config, params) {

// Run global promise first
.then(function () {
if (_.isFunction(threadneedle._globalOptions.before) && !require('./localOnly')(config, 'before')) {
if (_.isFunction(threadneedle._globalOptions.before) && !localOnly(config, 'before')) {
return when(threadneedle._globalOptions.before(params));
}
})
Expand Down
3 changes: 2 additions & 1 deletion lib/addMethod/globalize/beforeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var when = require('when');
var _ = require('lodash');

var localOnly = require('./localOnly');

module.exports = function (config, request, params) {
var threadneedle = this;
Expand All @@ -13,7 +14,7 @@ module.exports = function (config, request, params) {

// Run global promise first
.then(function () {
if (_.isFunction(threadneedle._globalOptions.beforeRequest) && !require('./localOnly')(config, 'beforeRequest')) {
if (_.isFunction(threadneedle._globalOptions.beforeRequest) && !localOnly(config, 'beforeRequest')) {
return when(threadneedle._globalOptions.beforeRequest(request, params));
}
})
Expand Down

0 comments on commit b918c9b

Please sign in to comment.