Class: Runcom::Config
- Inherits:
-
Object
- Object
- Runcom::Config
- Extended by:
- Forwardable
- Defined in:
- lib/runcom/config.rb
Overview
A developer friendly wrapper of XDG config.
Constant Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
:reek:FeatureEnvy.
- #hash ⇒ Object
-
#initialize(path, defaults: {}, context: DEFAULT_CONTEXT) ⇒ Config
constructor
A new instance of Config.
- #merge(other) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(path, defaults: {}, context: DEFAULT_CONTEXT) ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 |
# File 'lib/runcom/config.rb', line 16 def initialize path, defaults: {}, context: DEFAULT_CONTEXT @common = Paths::Common.new path, context: context @context = context @settings = defaults.deep_merge process_settings freeze end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
:reek:FeatureEnvy
28 29 30 |
# File 'lib/runcom/config.rb', line 28 def == other other.is_a?(Config) && hash == other.hash end |
#hash ⇒ Object
34 35 36 |
# File 'lib/runcom/config.rb', line 34 def hash [common.relative, to_h, self.class].hash end |
#merge(other) ⇒ Object
23 24 25 |
# File 'lib/runcom/config.rb', line 23 def merge other self.class.new common.relative, defaults: settings.deep_merge(other.to_h), context: context end |
#to_h ⇒ Object
38 39 40 |
# File 'lib/runcom/config.rb', line 38 def to_h settings end |