Class: ROM::Repository::Base
- Inherits:
-
Object
- Object
- ROM::Repository::Base
- Includes:
- Options
- Defined in:
- lib/rom/repository/base.rb
Overview
Abstract repository class to inherit from
TODO: rename this to Repository once deprecated Repository from rom core is gone
Class Method Summary collapse
-
.relations(*names) ⇒ Array<Symbol>
Define which relations your repository is going to use.
Instance Method Summary collapse
-
#initialize(env, options = {}) ⇒ Base
constructor
private
A new instance of Base.
Constructor Details
#initialize(env, options = {}) ⇒ Base
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.
Returns a new instance of Base.
45 46 47 48 49 50 51 52 53 |
# File 'lib/rom/repository/base.rb', line 45 def initialize(env, = {}) super self.class.relations.each do |name| proxy = LoadingProxy.new( env.relation(name), name: name, mapper_builder: mapper_builder ) instance_variable_set("@#{name}", proxy) end end |
Class Method Details
.relations(*names) ⇒ Array<Symbol>
Define which relations your repository is going to use
35 36 37 38 39 40 41 42 |
# File 'lib/rom/repository/base.rb', line 35 def self.relations(*names) if names.any? attr_reader(*names) @relations = names else @relations end end |