Created
November 6, 2013 15:35
-
-
Save BlessYAHU/7338106 to your computer and use it in GitHub Desktop.
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
augmentProduct = function (findEmployee, carrierName, product) { | |
var view = this, | |
augmentedProduct = _.clone(product); | |
var augEmpRates = _.map(augmentedProduct.employeeRates, function (currRate) { | |
var augEmpRate = _.extend(currRate, { employee: {} }); | |
return augEmpRate; | |
} | |
augmentedProduct.employeeRates = augEmpRates; | |
return augmentedProduct; | |
}; | |
augmentCarriers = function (getMatchingEmployee, carrierData) { | |
// clone object (so we don't mutate the original) | |
var augmentedData = _.clone(carrierData); | |
// for each carrier | |
return _.map(augmentedData, function (item) { | |
// augment products collection with employee collection | |
var carrierName = item.carrier.name; | |
item.products = _.map(item.products, _.partial(augmentProduct, getMatchingEmployee, carrierName)); | |
return item; | |
}); | |
// return augmented carrier data | |
return augmentData; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment