MCPcopy
hub / github.com/sequelize/sequelize / refreshAttributes

Method refreshAttributes

lib/model.js:1082–1271  ·  lib/model.js::Model.refreshAttributes
()

Source from the content-addressed store, hash-verified

1080 }
1081
1082 static refreshAttributes() {
1083 const attributeManipulation = {};
1084
1085 this.prototype._customGetters = {};
1086 this.prototype._customSetters = {};
1087
1088 [class="st">'get', class="st">'set'].forEach(type => {
1089 const opt = `${type}terMethods`;
1090 const funcs = { ...this.options[opt] };
1091 const _custom = type === class="st">'get' ? this.prototype._customGetters : this.prototype._customSetters;
1092
1093 _.each(funcs, (method, attribute) => {
1094 _custom[attribute] = method;
1095
1096 if (type === class="st">'get') {
1097 funcs[attribute] = function() {
1098 return this.get(attribute);
1099 };
1100 }
1101 if (type === class="st">'set') {
1102 funcs[attribute] = function(value) {
1103 return this.set(attribute, value);
1104 };
1105 }
1106 });
1107
1108 _.each(this.rawAttributes, (options, attribute) => {
1109 if (Object.prototype.hasOwnProperty.call(options, type)) {
1110 _custom[attribute] = options[type];
1111 }
1112
1113 if (type === class="st">'get') {
1114 funcs[attribute] = function() {
1115 return this.get(attribute);
1116 };
1117 }
1118 if (type === class="st">'set') {
1119 funcs[attribute] = function(value) {
1120 return this.set(attribute, value);
1121 };
1122 }
1123 });
1124
1125 _.each(funcs, (fct, name) => {
1126 if (!attributeManipulation[name]) {
1127 attributeManipulation[name] = {
1128 configurable: true
1129 };
1130 }
1131 attributeManipulation[name][type] = fct;
1132 });
1133 });
1134
1135 this._dataTypeChanges = {};
1136 this._dataTypeSanitizers = {};
1137
1138 this._hasBooleanAttributes = false;
1139 this._hasDateAttributes = false;

Callers 7

initMethod · 0.95
removeAttributeMethod · 0.95
_injectAttributesMethod · 0.80
_injectAttributesMethod · 0.80
_injectAttributesMethod · 0.80
_injectAttributesMethod · 0.80

Calls 8

getMethod · 0.95
setMethod · 0.95
_conformIndexMethod · 0.95
getTableNameMethod · 0.95
normalizeDataTypeMethod · 0.80
logMethod · 0.80
addMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected