Class: Async::Service::Configuration
- Inherits:
-
Object
- Object
- Async::Service::Configuration
- Defined in:
- lib/async/service/configuration.rb
Overview
Manages environments which describes how to host a specific set of services.
Environments are key-value maps with lazy value resolution. An environment can inherit from a parent environment, which can provide defaults
Instance Attribute Summary collapse
-
#environments ⇒ Object
readonly
Returns the value of attribute environments.
Class Method Summary collapse
Instance Method Summary collapse
-
#add(environment) ⇒ Object
Add the environment to the configuration.
- #controller(**options) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(environments = []) ⇒ Configuration
constructor
Initialize an empty configuration.
-
#load_file(path) ⇒ Object
Load the specified configuration file.
- #services(implementing: nil) ⇒ Object
Constructor Details
#initialize(environments = []) ⇒ Configuration
Initialize an empty configuration.
31 32 33 |
# File 'lib/async/service/configuration.rb', line 31 def initialize(environments = []) @environments = environments end |
Instance Attribute Details
#environments ⇒ Object (readonly)
Returns the value of attribute environments.
35 36 37 |
# File 'lib/async/service/configuration.rb', line 35 def environments @environments end |
Class Method Details
.for(*environments) ⇒ Object
26 27 28 |
# File 'lib/async/service/configuration.rb', line 26 def self.for(*environments) self.new(environments) end |
.load(paths = ARGV) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/async/service/configuration.rb', line 16 def self.load(paths = ARGV) configuration = self.new paths.each do |path| configuration.load_file(path) end return configuration end |
Instance Method Details
#add(environment) ⇒ Object
Add the environment to the configuration.
56 57 58 |
# File 'lib/async/service/configuration.rb', line 56 def add(environment) @environments << environment end |
#controller(**options) ⇒ Object
51 52 53 |
# File 'lib/async/service/configuration.rb', line 51 def controller(**) Controller.new(self.services(**).to_a) end |
#empty? ⇒ Boolean
37 38 39 |
# File 'lib/async/service/configuration.rb', line 37 def empty? @environments.empty? end |
#load_file(path) ⇒ Object
Load the specified configuration file. See Loader#load_file for more details.
61 62 63 |
# File 'lib/async/service/configuration.rb', line 61 def load_file(path) Loader.load_file(self, path) end |
#services(implementing: nil) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/async/service/configuration.rb', line 41 def services(implementing: nil) return to_enum(:services, implementing: implementing) unless block_given? @environments.each do |environment| next if implementing and environment.implements?(implementing) yield Generic.wrap(environment) end end |