Class: Eien::LocalConfig
- Inherits:
-
Object
- Object
- Eien::LocalConfig
- Defined in:
- lib/eien/local_config.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#context ⇒ Object
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/eien/local_config.rb', line 5 def app @app end |
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/eien/local_config.rb', line 5 def context @context end |
Class Method Details
.build ⇒ Object
7 8 9 |
# File 'lib/eien/local_config.rb', line 7 def self.build new.tap(&:load!) end |
Instance Method Details
#load! ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/eien/local_config.rb', line 11 def load! return unless File.exist?(config_path) config = YAML.load_file(config_path).deep_symbolize_keys @context = config[:context] @app = config[:app] end |
#save! ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/eien/local_config.rb', line 19 def save! config = { context: context, app: app, }.compact.deep_stringify_keys FileUtils.mkdir_p(config_dir) File.write(config_path, config.to_yaml) end |