Skip to content

Instantly share code, notes, and snippets.

@JasonOffutt
Last active December 21, 2015 19:48
Show Gist options
  • Save JasonOffutt/6356313 to your computer and use it in GitHub Desktop.
Save JasonOffutt/6356313 to your computer and use it in GitHub Desktop.
Rock settings module
(function () {
'use strict';
window.Rock = window.Rock || {};
Rock.settings = (function () {
var _settings = {},
exports = {
initialize: function (options) {
if (typeof options === 'object') {
_settings = options;
}
},
get: function (key) {
return _settings[key];
},
insert: function (key, value) {
_settings[key] = value;
},
remove: function (key) {
if (_settings[key]) {
delete _settings[key];
}
}
};
return exports;
}());
}());
// Instead of accessing a "global setting" this way:
var baseUrl = rock.baseUrl;
// We'd access it this way:
var baseUrl = Rock.settings.get('baseUrl');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment