Skip to content

Instantly share code, notes, and snippets.

@gabriel403
Created October 3, 2012 11:00
Show Gist options
  • Save gabriel403/3826400 to your computer and use it in GitHub Desktop.
Save gabriel403/3826400 to your computer and use it in GitHub Desktop.
a simple base class for having setters and getters by default
define(["dojo/_base/declare", "dojo/_base/lang", "gmk/library/utilities/string"],
function(declare, lang, strUtil){
return declare([ ], {
get: function(varName) {
var retVal = null;
if ( "function" == typeof lang.getObject("get"+strUtil.ucfirst(varName), false, this) ) {
retVal = lang.getObject("get"+strUtil.ucfirst(varName), false, this)();
} else {
retVal = lang.getObject(varName, false, this);
}
return retVal;
},
set: function(varName, value) {
if ( "function" == typeof lang.getObject("set"+strUtil.ucfirst(varName), false, this) ) {
lang.getObject("set"+strUtil.ucfirst(varName), false, this)(value);
} else {
lang.setObject(varName, value, this);
}
return this;
}
});
});
define(["dojo/_base/declare", "gmk/library/base/mvc/view"],
function(declare, baseView){
return declare([baseView], {
someVar: null,
someOtherVar: null,
constructor: function(props) {
this.set("someVar","somevalue");
this.set("someOtherVar",5);
},
setSomeOtherVar: function(value){
this.someOtherVar = ++value;
}
});
});
define([], function(){
return {
ucfirst: function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
}
});
define(["dojo/_base/declare", "dojo/_base/lang", "gmk/library/base/getterSetterBase"],
function(declare, lang, getterSetterBase){
return declare([getterSetterBase], {
setupDom: function() {
},
setupDijits: function() {
},
setupConnections: function() {
},
init : function() {
this.setupDom();
this.setupDijits();
this.setupConnections();
},
constructor: function(props) {
lang.mixin(this, props);
this.init();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment