Class: ROM::Repository
- Inherits:
-
Object
- Object
- ROM::Repository
- Extended by:
- Dry::Core::Cache, Dry::Core::ClassAttributes, ClassInterface
- Defined in:
- repository/lib/rom/repository.rb,
repository/lib/rom/repository/root.rb,
repository/lib/rom/repository/version.rb,
repository/lib/rom/repository/class_interface.rb,
repository/lib/rom/repository/relation_reader.rb
Overview
Abstract repository class to inherit from
A repository provides access to composable relations and commands. Its job is to provide application-specific data that is already materialized, so that relations don't leak into your application layer.
Typically, you're going to work with Repository::Root that is configured to use a single relation as its root, and compose aggregates and use changesets and commands against the root relation.
Direct Known Subclasses
Defined Under Namespace
Modules: ClassInterface Classes: Root
Constant Summary collapse
- VERSION =
'5.2.1'
Instance Attribute Summary collapse
-
#auto_struct ⇒ Boolean
readonly
The container used to set up a repo.
-
#container ⇒ ROM::Container
readonly
The container used to set up a repo.
- #relations ⇒ Object readonly
-
#struct_namespace ⇒ Module, Class
readonly
The namespace for auto-generated structs.
Class Method Summary collapse
-
.[](name) ⇒ Class
extended
from ClassInterface
Create a root-repository class and set its root relation.
-
.auto_struct ⇒ Object
Get or set struct namespace.
-
.commands(*names, mapper: nil, use: nil, plugins_options: EMPTY_HASH, **opts) ⇒ Array<Symbol>
extended
from ClassInterface
Defines command methods on a root repository.
-
.new(container = nil, **options) ⇒ Object
extended
from ClassInterface
Initialize a new repository object, establishing configured relation proxies from the passed container.
-
.relation_reader ⇒ RelationReader
Get or set relation reader module.
- .use(plugin, **options) ⇒ Object extended from ClassInterface
Instance Method Summary collapse
-
#inspect ⇒ String
Return a string representation of a repository object.
-
#transaction(&block) ⇒ Object
Open a database transaction.
Instance Attribute Details
#auto_struct ⇒ Boolean (readonly)
Returns The container used to set up a repo.
101 |
# File 'repository/lib/rom/repository.rb', line 101 option :auto_struct, default: -> { self.class.auto_struct } |
#container ⇒ ROM::Container (readonly)
Returns The container used to set up a repo.
93 |
# File 'repository/lib/rom/repository.rb', line 93 option :container, allow: ROM::Container |
#relations ⇒ Object (readonly)
105 106 107 |
# File 'repository/lib/rom/repository.rb', line 105 def relations @relations end |
#struct_namespace ⇒ Module, Class (readonly)
Returns The namespace for auto-generated structs.
97 |
# File 'repository/lib/rom/repository.rb', line 97 option :struct_namespace, default: -> { self.class.struct_namespace } |
Class Method Details
.[](name) ⇒ Class Originally defined in module ClassInterface
Create a root-repository class and set its root relation
.auto_struct ⇒ Object
Get or set struct namespace
76 |
# File 'repository/lib/rom/repository.rb', line 76 defines :auto_struct |
.commands(*names, mapper: nil, use: nil, plugins_options: EMPTY_HASH, **opts) ⇒ Array<Symbol> Originally defined in module ClassInterface
Defines command methods on a root repository
#new(container, **options) ⇒ Object #new(**options) ⇒ Object Originally defined in module ClassInterface
Initialize a new repository object, establishing configured relation proxies from the passed container
.relation_reader ⇒ RelationReader
Get or set relation reader module
87 |
# File 'repository/lib/rom/repository.rb', line 87 defines :relation_reader |
.use(plugin, **options) ⇒ Object Originally defined in module ClassInterface
Instance Method Details
#inspect ⇒ String
Return a string representation of a repository object
145 146 147 |
# File 'repository/lib/rom/repository.rb', line 145 def inspect %(#<#{self.class} struct_namespace=#{struct_namespace} auto_struct=#{auto_struct}>) end |
#transaction(&block) ⇒ Object
Open a database transaction
136 137 138 |
# File 'repository/lib/rom/repository.rb', line 136 def transaction(&block) container.gateways[:default].transaction(&block) end |