Last active
December 1, 2015 14:27
-
-
Save barrydobson/62a9da63e18ce82ac40c to your computer and use it in GitHub Desktop.
Our implementation of the room rate source chain. It executes the source, then runs through all the modifiers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
module.exports = function roomRateSourceChain(originalSource, modifiers) { | |
return { | |
getRoomRates: function () { | |
var originalArguments = [].slice.call(arguments); | |
return originalSource.apply(null, originalArguments) | |
.then(function (roomRates) { | |
originalArguments.unshift(roomRates); | |
return Promise.reduce(modifiers, function (resultsFromPrevious, modifier) { | |
originalArguments[0] = resultsFromPrevious; | |
return modifier.apply(null, originalArguments); | |
}, roomRates); | |
}); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment