Skip to content

Instantly share code, notes, and snippets.

@adros
Forked from ondrek/pattern.js
Last active August 29, 2015 14:19
Show Gist options
  • Save adros/a409f8ac532b399f9c9e to your computer and use it in GitHub Desktop.
Save adros/a409f8ac532b399f9c9e to your computer and use it in GitHub Desktop.
;(function(){
"use strict";
// framework
window.$config = function(){
var Config = function(){};
var selves = [];
Config.prototype = {
get $set(){ var self={}; selves.push(self); return self; },
get $get(){ return mixin(selves); }
};
return new Config();
function mixin(array){
return array.reduce(function(obj, item){
for(var p in item){obj[p]=item[p];}
return obj;
},{})
}
};
// dev
var config = $config();
config.$set.REST_API = "/oauth/rest/v2/";
config.$set.IS_DEVELOPMENT = true;
console.debug(config.$get.IS_DEVELOPMENT); // > true
console.debug(config.$get.REST_API); // > "/oauth/rest/v2/"
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment