Skip to content

Instantly share code, notes, and snippets.

@renatodex
Created September 12, 2016 18:12
Show Gist options
  • Save renatodex/9f787607b79eda1f1ff25d18ee93d490 to your computer and use it in GitHub Desktop.
Save renatodex/9f787607b79eda1f1ff25d18ee93d490 to your computer and use it in GitHub Desktop.
App Model Idea
var AppModel = function() {
this.extend = function(model_setup) {
return function(model_data) {
return new factory_methods(model_setup, model_data);
}
}
this.factory_methods = function(model_setup, model_data) {
var custom_methods = model_setup["methods"];
var base_methods = {
get: function(key){
return model_data[key];
},
set: function(key, value) {
model_data[key] = value;
},
attributes: function() {
return model_data;
}
}
return $.extend(base_methods, custom_methods);
}
return {
extend: extend
}
}();
@jotafeldmann
Copy link

Faz sentido uma abordagem com 1 e 2. Só acho que validação é inerente quando falamos de model, ainda que desacoplados.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment