diff options
author | Samy Pessé <samypesse@gmail.com> | 2017-02-17 21:08:00 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2017-02-17 21:08:00 +0100 |
commit | dd43b0a6091ef3c830d92305cb57ab3c19eaf998 (patch) | |
tree | 976bee1d1bef641aec9a715da6e512afe6350561 /packages/gitbook-core/src/models/Config.js | |
parent | 0198dd291a93e6a577af082b798385d5498b6ec3 (diff) | |
download | gitbook-dd43b0a6091ef3c830d92305cb57ab3c19eaf998.zip gitbook-dd43b0a6091ef3c830d92305cb57ab3c19eaf998.tar.gz gitbook-dd43b0a6091ef3c830d92305cb57ab3c19eaf998.tar.bz2 |
Add model for config instead of using fromJS
Diffstat (limited to 'packages/gitbook-core/src/models/Config.js')
-rw-r--r-- | packages/gitbook-core/src/models/Config.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/models/Config.js b/packages/gitbook-core/src/models/Config.js new file mode 100644 index 0000000..50abef2 --- /dev/null +++ b/packages/gitbook-core/src/models/Config.js @@ -0,0 +1,32 @@ +const { Map, fromJS } = require('immutable'); + +/** + * Configuration from the book. + * @type {Class} + */ +class Config extends Map { + + /** + * Create a config instance from values. + * @param {Mixed} values + * @return {Config} + */ + static create(values) { + return values instanceof Config ? + values : new Config(fromJS(values)); + } + + /** + * Get configuration for a plugin. + * @param {String} pluginName + * @return {Map} + */ + getForPlugin(pluginName) { + return this.getIn([ + 'pluginsConfig', pluginName + ]); + } + +} + +module.exports = Config; |