Class: ROM::Container
- Inherits:
-
Object
- Object
- ROM::Container
- Includes:
- Dry::Container::Mixin
- Defined in:
- core/lib/rom/container.rb
Overview
ROM container is an isolated environment with no global state where all components are registered. Container objects provide access to your relations, commands and mappers. ROM containers are usually configured and handled via framework integrations, although it is easy to use them standalone.
There are 3 types of container setup:
- Setup DSL - a simple block-based configuration which allows configuring all components and gives you back a container instance. This type is suitable for small scripts, or in some cases rake tasks
- Explicit setup - this type requires creating a configuration object, registering component classes (ie relation classes) and passing the config to container builder function. This type is suitable when your environment is not typical and you need full control over component registration
- Explicit setup with auto-registration - same as explicit setup but allows you to configure auto-registration mechanism which will register component classes for you, based on dir/file naming conventions. This is the most common type of setup that's used by framework integrations
Instance Method Summary collapse
-
#commands ⇒ Hash<Symbol=>CommandRegistry]
Return command registry.
-
#disconnect ⇒ Hash<Symbol=>Gateway>
Disconnect all gateways.
-
#gateways ⇒ Hash<Symbol=>Gateway>
Return registered gateways.
-
#mappers ⇒ Hash<Symbol=>MapperRegistry]
Return mapper registry for all relations.
-
#relations ⇒ RelationRegistry
Return relation registry.
Instance Method Details
#commands ⇒ Hash<Symbol=>CommandRegistry]
Return command registry
147 148 149 |
# File 'core/lib/rom/container.rb', line 147 def commands self[:commands] end |
#disconnect ⇒ Hash<Symbol=>Gateway>
Disconnect all gateways
161 162 163 |
# File 'core/lib/rom/container.rb', line 161 def disconnect gateways.each_value(&:disconnect) end |
#gateways ⇒ Hash<Symbol=>Gateway>
Return registered gateways
120 121 122 |
# File 'core/lib/rom/container.rb', line 120 def gateways self[:gateways] end |
#mappers ⇒ Hash<Symbol=>MapperRegistry]
Return mapper registry for all relations
129 130 131 |
# File 'core/lib/rom/container.rb', line 129 def mappers self[:mappers] end |
#relations ⇒ RelationRegistry
Return relation registry
138 139 140 |
# File 'core/lib/rom/container.rb', line 138 def relations self[:relations] end |