File tree 4 files changed +32
-74
lines changed
4 files changed +32
-74
lines changed Original file line number Diff line number Diff line change 16
16
# rom Global
17
17
require "rom/global"
18
18
19
- # rom configurations
20
- require "rom/configuration"
21
-
22
19
# container with registries
23
20
require "rom/container"
24
21
25
- # container factory
26
- require "rom/create_container"
27
-
28
22
# register known plugin types
29
23
require "rom/schema_plugin"
30
24
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
+ require "dry/effects"
4
+
3
5
require "rom/plugin_registry"
4
6
require "rom/global/plugin_dsl"
7
+ require "rom/configuration"
8
+ require "rom/setup/finalize"
9
+
5
10
6
11
module ROM
7
12
# Globally accessible public interface exposed via ROM module
8
13
#
9
14
# @api public
10
15
module Global
16
+ include Dry ::Effects ::Handler . Reader ( :configuration )
17
+
11
18
# Set base global registries in ROM constant
12
19
#
13
20
# @api private
@@ -32,6 +39,29 @@ def self.extended(rom)
32
39
# @api private
33
40
attr_reader :plugin_registry
34
41
42
+ # @api public
43
+ def container ( *args , &block )
44
+ configuration =
45
+ case args . first
46
+ when Configuration
47
+ args . first
48
+ else
49
+ Configuration . new ( *args , &block )
50
+ end
51
+
52
+ configuration . configure do |config |
53
+ configuration . gateways . each_key do |key |
54
+ gateway_config = config . gateways [ key ]
55
+ gateway_config . infer_relations = true unless gateway_config . key? ( :infer_relations )
56
+ end
57
+ end
58
+
59
+ with_configuration ( configuration ) do
60
+ finalize = Finalize . new ( configuration )
61
+ finalize . run!
62
+ end
63
+ end
64
+
35
65
# Global plugin setup DSL
36
66
#
37
67
# @example
Original file line number Diff line number Diff line change 2
2
3
3
require "spec_helper"
4
4
5
- RSpec . describe ROM ::CreateContainer , "#finalize " do
6
- describe "#finalize " do
5
+ RSpec . describe ROM ::Global , "#container " do
6
+ context "with configuration " do
7
7
include_context "container"
8
8
9
9
it "can register multiple relations with same dataset" do
You can’t perform that action at this time.
0 commit comments