Module: SenroUsecaser
- Defined in:
- lib/senro_usecaser.rb,
lib/senro_usecaser/base.rb,
lib/senro_usecaser/hook.rb,
lib/senro_usecaser/error.rb,
lib/senro_usecaser/result.rb,
lib/senro_usecaser/version.rb,
lib/senro_usecaser/provider.rb,
lib/senro_usecaser/container.rb,
lib/senro_usecaser/depends_on.rb,
lib/senro_usecaser/configuration.rb,
lib/senro_usecaser/retry_context.rb,
lib/senro_usecaser/retry_configuration.rb
Overview
rbs_inline: enabled
Defined Under Namespace
Modules: DependsOn Classes: Base, Configuration, Container, Environment, Error, Hook, Provider, ProviderBooter, Result, RetryConfiguration, RetryContext, SingletonRegistration, Step
Constant Summary collapse
- VERSION =
: String
"0.4.2"
Class Attribute Summary collapse
-
.container ⇒ Object
Returns the global container instance.
Class Method Summary collapse
-
.boot! ⇒ Object
Boots all configured providers in dependency order.
-
.configuration ⇒ Object
Returns the configuration instance.
-
.configure {|configuration| ... } ⇒ Object
Configures SenroUsecaser.
-
.env ⇒ Object
Returns the current environment.
-
.env=(name) ⇒ Object
Sets the environment.
-
.register_provider(provider_class) ⇒ Object
Registers a provider to the global container.
-
.register_providers(*provider_classes) ⇒ Object
Registers multiple providers to the global container.
-
.reset! ⇒ Object
Resets all state (useful for testing).
-
.reset_container! ⇒ Object
Resets the global container (useful for testing).
-
.shutdown! ⇒ Object
Shuts down all booted providers.
Class Attribute Details
.container ⇒ Object
Returns the global container instance
: () -> Container
44 45 46 |
# File 'lib/senro_usecaser.rb', line 44 def container @container ||= Container.new end |
Class Method Details
.boot! ⇒ Object
Boots all configured providers in dependency order
: () -> void
112 113 114 115 |
# File 'lib/senro_usecaser.rb', line 112 def boot! @booter = ProviderBooter.new(configuration.providers, container) @booter.boot! end |
.configuration ⇒ Object
Returns the configuration instance
: () -> Configuration
86 87 88 |
# File 'lib/senro_usecaser.rb', line 86 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Configures SenroUsecaser
: () { (Configuration) -> void } -> void
99 100 101 |
# File 'lib/senro_usecaser.rb', line 99 def configure yield configuration end |
.env ⇒ Object
Returns the current environment
: () -> Environment
131 132 133 |
# File 'lib/senro_usecaser.rb', line 131 def env @env ||= Environment.new(detect_environment) end |
.env=(name) ⇒ Object
Sets the environment
: (String) -> void
138 139 140 |
# File 'lib/senro_usecaser.rb', line 138 def env=(name) @env = Environment.new(name) end |
.register_provider(provider_class) ⇒ Object
Registers a provider to the global container
: (singleton(Provider)) -> void
69 70 71 |
# File 'lib/senro_usecaser.rb', line 69 def register_provider(provider_class) provider_class.call(container) end |
.register_providers(*provider_classes) ⇒ Object
Registers multiple providers to the global container
: (*singleton(Provider)) -> void
79 80 81 |
# File 'lib/senro_usecaser.rb', line 79 def register_providers(*provider_classes) provider_classes.each { |klass| register_provider(klass) } end |
.reset! ⇒ Object
Resets all state (useful for testing)
: () -> void
145 146 147 148 149 150 |
# File 'lib/senro_usecaser.rb', line 145 def reset! @container = nil @configuration = nil @booter = nil @env = nil end |
.reset_container! ⇒ Object
Resets the global container (useful for testing)
: () -> void
59 60 61 |
# File 'lib/senro_usecaser.rb', line 59 def reset_container! @container = nil end |
.shutdown! ⇒ Object
Shuts down all booted providers
: () -> void
120 121 122 |
# File 'lib/senro_usecaser.rb', line 120 def shutdown! @booter&.shutdown! end |