Created
September 12, 2016 18:12
-
-
Save renatodex/9f787607b79eda1f1ff25d18ee93d490 to your computer and use it in GitHub Desktop.
App Model Idea
This file contains hidden or 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 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 | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Faz sentido uma abordagem com 1 e 2. Só acho que validação é inerente quando falamos de model, ainda que desacoplados.