Last active
December 21, 2015 19:48
-
-
Save JasonOffutt/6356313 to your computer and use it in GitHub Desktop.
Rock settings module
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
(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; | |
}()); | |
}()); |
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
// 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