Class: ConfigX::Builder
- Inherits:
-
Object
- Object
- ConfigX::Builder
- Defined in:
- lib/config_x/builder.rb
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_source(source, **args) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
-
#load ⇒ Object
Loads config in the following order: 1.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
28 29 30 |
# File 'lib/config_x/builder.rb', line 28 def initialize @sources = [] end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
32 33 34 |
# File 'lib/config_x/builder.rb', line 32 def sources @sources end |
Class Method Details
.load ⇒ Object
19 20 21 |
# File 'lib/config_x/builder.rb', line 19 def load(...) new(...).load end |
.source(source, **args) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/config_x/builder.rb', line 8 def source(source, **args) case source in Source then source in Hash then HashSource.new(source) in String then FileSource.new(source) in Pathname then FileSource.new(source) in ENV then EnvSource.new(ENV, **args) end end |
Instance Method Details
#==(other) ⇒ Object
47 48 49 |
# File 'lib/config_x/builder.rb', line 47 def ==(other) other.is_a?(self.class) && other.sources == sources end |
#add_source(source, **args) ⇒ Object
34 35 36 37 |
# File 'lib/config_x/builder.rb', line 34 def add_source(source, **args) sources << self.class.source(source, **args) self end |