Skip to content

Instantly share code, notes, and snippets.

@Quixomatic
Created February 10, 2016 18:16
Show Gist options
  • Select an option

  • Save Quixomatic/ab78c394bdb5828b0634 to your computer and use it in GitHub Desktop.

Select an option

Save Quixomatic/ab78c394bdb5828b0634 to your computer and use it in GitHub Desktop.
var convertOptions = function (obj) {
var temp = [];
var tempFunctionArray = [];
// Pre Create
if (obj.preCreate !== undefined) {
temp = obj.preCreate.split(',');
tempFunctionArray = [];
for (var i = 0; i < temp.length; i++) {
tempFunctionArray.push(function_array[temp[i]]);
}
obj.preCreate = tempFunctionArray;
}
// Pre Read
if (obj.preRead !== undefined) {
temp = obj.preRead.split(',');
tempFunctionArray = [];
for (var i = 0; i < temp.length; i++) {
tempFunctionArray.push(function_array[temp[i]]);
}
obj.preRead = tempFunctionArray;
}
// Pre Delete
if (obj.preDelete !== undefined) {
temp = obj.preDelete.split(',');
tempFunctionArray = [];
for (var i = 0; i < temp.length; i++) {
tempFunctionArray.push(function_array[temp[i]]);
}
obj.preDelete = tempFunctionArray;
}
// Post Create
if (obj.postCreate !== undefined) {
temp = obj.postCreate.split(',');
tempFunctionArray = [];
for (var i = 0; i < temp.length; i++) {
tempFunctionArray.push(function_array[temp[i]]);
}
obj.postCreate = tempFunctionArray;
}
// Post Update
if (obj.postUpdate !== undefined) {
temp = obj.postUpdate.split(',');
tempFunctionArray = [];
for (var i = 0; i < temp.length; i++) {
tempFunctionArray.push(function_array[temp[i]]);
}
obj.postUpdate = tempFunctionArray;
}
return obj;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment