Class: Rigit::Config
- Inherits:
-
Object
- Object
- Rigit::Config
- Defined in:
- lib/rigit/config.rb
Overview
Handles the rig config file. Usage example:
Config.load 'path/to.yml'
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.load(path) ⇒ Object
Returns a new
configatroninstance, after loading from a YAML file.
Instance Method Summary collapse
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
- #settings ⇒ Object
- #settings! ⇒ Object
Constructor Details
#initialize(path) ⇒ Config
Returns a new instance of Config.
18 19 20 |
# File 'lib/rigit/config.rb', line 18 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/rigit/config.rb', line 11 def path @path end |
Class Method Details
.load(path) ⇒ Object
Returns a new configatron instance, after loading from a YAML file.
14 15 16 |
# File 'lib/rigit/config.rb', line 14 def self.load(path) new(path).settings end |
Instance Method Details
#settings ⇒ Object
22 23 24 |
# File 'lib/rigit/config.rb', line 22 def settings @settings ||= settings! end |
#settings! ⇒ Object
26 27 28 29 30 |
# File 'lib/rigit/config.rb', line 26 def settings! settings = Configatron::RootStore.new settings.configure_from_hash YAML.load_file(path) if File.exist? path settings end |