Created
September 14, 2013 12:05
-
-
Save A/6561484 to your computer and use it in GitHub Desktop.
ZOMG TEH INHERITANCE!
This file contains 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
'use strict'; | |
var shrtAttrs = require('shortcode-params'); | |
var util = require('util'); | |
var SuperModule = function (params) { | |
this.attributes = shrtAttrs(this.defaults, params); | |
this.set = function(key,val) { | |
this.attributes[key] = val; | |
}; | |
this.get = function(key) { | |
return (key)?this.attributes[key]:this.attributes; | |
}; | |
}; | |
var TextModule = function(params) { | |
this.defaults = { | |
majorParam_1: '.js_mymodule', | |
majorParam_2: 1, | |
majorParam_3: false, | |
majorParam_4: undefined, | |
minorParam_1: 'purchased', | |
minorParam_2: 'purchase', | |
minorParam_3: 'purchased' | |
}; | |
SuperModule.call(this,params); | |
}; | |
util.inherits(TextModule,SuperModule); | |
var textModule = new TextModule({ | |
majorParam_1: 'omg!!!!1!1121', | |
majorParam_2: 'this', | |
majorParam_3: 'shit', | |
majorParam_4: 'realy', | |
minorParam_1: 'works!' | |
}); | |
console.log(textModule.get()); | |
// Result: | |
// { majorParam_1: 'omg!!!!1!1121', | |
// majorParam_2: 'this', | |
// majorParam_3: 'shit', | |
// majorParam_4: 'realy', | |
// minorParam_1: 'works!', | |
// minorParam_2: 'purchase', | |
// minorParam_3: 'purchased' | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment