Class: ROM::Repository
- Inherits:
-
Object
- Object
- ROM::Repository
- Extended by:
- Dry::Core::Cache, Dry::Core::ClassAttributes, Initializer, ClassInterface
- Defined in:
- lib/rom/repository.rb,
lib/rom/repository/root.rb,
lib/rom/repository/version.rb,
lib/rom/repository/class_interface.rb,
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: RelationReader, Root
Constant Summary collapse
- VERSION =
'5.3.0'
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
-
.auto_struct ⇒ Object
Get or set struct namespace.
-
.relation_reader ⇒ RelationReader
Get or set relation reader module.
Instance Method Summary collapse
-
#initialize ⇒ Repository
constructor
private
Initializes a new repository object.
-
#inspect ⇒ String
Return a string representation of a repository object.
-
#transaction(*args, &block) ⇒ Object
Open a database transaction.
Methods included from ClassInterface
[], commands, inherited, new, use
Constructor Details
#initialize ⇒ Repository
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new repository object
107 108 109 110 |
# File 'lib/rom/repository.rb', line 107 def initialize(*) super @relations = {} end |
Instance Attribute Details
#auto_struct ⇒ Boolean (readonly)
Returns The container used to set up a repo.
98 |
# File 'lib/rom/repository.rb', line 98 option :auto_struct, default: -> { self.class.auto_struct } |
#container ⇒ ROM::Container (readonly)
Returns The container used to set up a repo.
90 |
# File 'lib/rom/repository.rb', line 90 option :container, allow: ROM::Container |
#relations ⇒ Object (readonly)
102 103 104 |
# File 'lib/rom/repository.rb', line 102 def relations @relations end |
#struct_namespace ⇒ Module, Class (readonly)
Returns The namespace for auto-generated structs.
94 |
# File 'lib/rom/repository.rb', line 94 option :struct_namespace, default: -> { self.class.struct_namespace } |
Class Method Details
.auto_struct ⇒ Object
Get or set struct namespace
73 |
# File 'lib/rom/repository.rb', line 73 defines :auto_struct |
.relation_reader ⇒ RelationReader
Get or set relation reader module
84 |
# File 'lib/rom/repository.rb', line 84 defines :relation_reader |
Instance Method Details
#inspect ⇒ String
Return a string representation of a repository object
155 156 157 |
# File 'lib/rom/repository.rb', line 155 def inspect %(#<#{self.class} struct_namespace=#{struct_namespace} auto_struct=#{auto_struct}>) end |
#transaction(*args, &block) ⇒ Object
Open a database transaction
146 147 148 |
# File 'lib/rom/repository.rb', line 146 def transaction(*args, &block) container.gateways[:default].transaction(*args, &block) end |