rom-core 5.3.2 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rom/array_dataset.rb +5 -5
  3. data/lib/rom/association_set.rb +1 -2
  4. data/lib/rom/associations/definitions/abstract.rb +5 -3
  5. data/lib/rom/associations/many_to_many.rb +1 -2
  6. data/lib/rom/attribute.rb +15 -37
  7. data/lib/rom/auto_curry.rb +34 -23
  8. data/lib/rom/cache.rb +9 -21
  9. data/lib/rom/command.rb +19 -37
  10. data/lib/rom/command_compiler.rb +12 -14
  11. data/lib/rom/command_proxy.rb +6 -10
  12. data/lib/rom/command_registry.rb +4 -8
  13. data/lib/rom/commands/class_interface.rb +20 -20
  14. data/lib/rom/commands/composite.rb +3 -0
  15. data/lib/rom/commands/graph/class_interface.rb +3 -1
  16. data/lib/rom/commands/graph/input_evaluator.rb +3 -1
  17. data/lib/rom/commands/graph.rb +3 -0
  18. data/lib/rom/commands/lazy/create.rb +2 -0
  19. data/lib/rom/commands/lazy/update.rb +2 -0
  20. data/lib/rom/commands/lazy.rb +2 -3
  21. data/lib/rom/configuration.rb +14 -16
  22. data/lib/rom/configuration_dsl/command.rb +2 -2
  23. data/lib/rom/configuration_dsl/command_dsl.rb +9 -5
  24. data/lib/rom/configuration_dsl/mapper_dsl.rb +12 -3
  25. data/lib/rom/configuration_dsl/relation.rb +4 -2
  26. data/lib/rom/configuration_dsl.rb +8 -10
  27. data/lib/rom/constants.rb +26 -26
  28. data/lib/rom/container.rb +15 -15
  29. data/lib/rom/core/version.rb +1 -1
  30. data/lib/rom/core.rb +0 -1
  31. data/lib/rom/create_container.rb +3 -5
  32. data/lib/rom/data_proxy.rb +13 -15
  33. data/lib/rom/enumerable_dataset.rb +6 -6
  34. data/lib/rom/environment.rb +5 -5
  35. data/lib/rom/gateway.rb +4 -12
  36. data/lib/rom/global/plugin_dsl.rb +4 -4
  37. data/lib/rom/global.rb +2 -2
  38. data/lib/rom/header/attribute.rb +1 -1
  39. data/lib/rom/header.rb +13 -35
  40. data/lib/rom/initializer.rb +11 -15
  41. data/lib/rom/lint/enumerable_dataset.rb +2 -1
  42. data/lib/rom/lint/gateway.rb +3 -1
  43. data/lib/rom/lint/linter.rb +2 -2
  44. data/lib/rom/lint/test.rb +4 -6
  45. data/lib/rom/mapper/attribute_dsl.rb +39 -27
  46. data/lib/rom/mapper/builder.rb +2 -2
  47. data/lib/rom/mapper/dsl.rb +2 -3
  48. data/lib/rom/mapper/model_dsl.rb +5 -1
  49. data/lib/rom/mapper.rb +2 -4
  50. data/lib/rom/mapper_compiler.rb +3 -2
  51. data/lib/rom/mapper_registry.rb +2 -4
  52. data/lib/rom/memory/commands.rb +1 -1
  53. data/lib/rom/memory/dataset.rb +7 -5
  54. data/lib/rom/memory/gateway.rb +1 -0
  55. data/lib/rom/model_builder.rb +14 -14
  56. data/lib/rom/open_struct.rb +1 -1
  57. data/lib/rom/pipeline.rb +6 -15
  58. data/lib/rom/plugin_registry.rb +4 -10
  59. data/lib/rom/plugins/command/timestamps.rb +9 -5
  60. data/lib/rom/plugins/relation/instrumentation.rb +7 -2
  61. data/lib/rom/plugins/relation/registry_reader.rb +3 -15
  62. data/lib/rom/plugins.rb +1 -3
  63. data/lib/rom/processor/transproc.rb +14 -4
  64. data/lib/rom/processor.rb +1 -0
  65. data/lib/rom/registry.rb +20 -29
  66. data/lib/rom/relation/class_interface.rb +18 -16
  67. data/lib/rom/relation/combined.rb +7 -4
  68. data/lib/rom/relation/composite.rb +2 -6
  69. data/lib/rom/relation/curried.rb +12 -11
  70. data/lib/rom/relation/graph.rb +4 -12
  71. data/lib/rom/relation/loaded.rb +8 -16
  72. data/lib/rom/relation/materializable.rb +6 -14
  73. data/lib/rom/relation/name.rb +5 -14
  74. data/lib/rom/relation/view_dsl.rb +7 -9
  75. data/lib/rom/relation/wrap.rb +3 -9
  76. data/lib/rom/relation.rb +39 -81
  77. data/lib/rom/schema/associations_dsl.rb +4 -8
  78. data/lib/rom/schema/dsl.rb +14 -13
  79. data/lib/rom/schema/inferrer.rb +5 -3
  80. data/lib/rom/schema.rb +27 -41
  81. data/lib/rom/setup/auto_registration.rb +4 -6
  82. data/lib/rom/setup/auto_registration_strategies/base.rb +1 -1
  83. data/lib/rom/setup/auto_registration_strategies/custom_namespace.rb +4 -8
  84. data/lib/rom/setup/finalize/finalize_commands.rb +3 -0
  85. data/lib/rom/setup/finalize/finalize_mappers.rb +16 -14
  86. data/lib/rom/setup/finalize/finalize_relations.rb +30 -4
  87. data/lib/rom/setup/finalize.rb +17 -3
  88. data/lib/rom/setup.rb +5 -4
  89. data/lib/rom/struct.rb +20 -18
  90. data/lib/rom/struct_compiler.rb +4 -7
  91. data/lib/rom/support/configurable.rb +10 -20
  92. data/lib/rom/support/memoizable.rb +10 -9
  93. data/lib/rom/support/notifications.rb +4 -8
  94. data/lib/rom/transaction.rb +2 -4
  95. data/lib/rom/transformer.rb +6 -10
  96. data/lib/rom/types.rb +3 -6
  97. metadata +15 -57
@@ -13,8 +13,8 @@ module ROM
13
13
  # @api private
14
14
  def inherited(klass)
15
15
  super
16
- klass.instance_variable_set(:'@before', before.dup)
17
- klass.instance_variable_set(:'@after', after.dup)
16
+ klass.instance_variable_set(:@before, before.dup)
17
+ klass.instance_variable_set(:@after, after.dup)
18
18
  end
19
19
 
20
20
  # Sets up the base class
@@ -84,12 +84,12 @@ module ROM
84
84
  # @return [Class, Object]
85
85
  #
86
86
  # @api public
87
- def create_class(name, type, &block)
87
+ def create_class(name, type, &)
88
88
  klass = Dry::Core::ClassBuilder
89
89
  .new(name: "#{Inflector.classify(type)}[:#{name}]", parent: type)
90
90
  .call
91
91
 
92
- if block
92
+ if block_given?
93
93
  yield(klass)
94
94
  else
95
95
  klass
@@ -163,10 +163,10 @@ module ROM
163
163
  #
164
164
  # @api public
165
165
  def before(*hooks)
166
- if !hooks.empty?
167
- set_hooks(:before, hooks)
168
- else
166
+ if hooks.empty?
169
167
  @before
168
+ else
169
+ set_hooks(:before, hooks)
170
170
  end
171
171
  end
172
172
 
@@ -208,10 +208,10 @@ module ROM
208
208
  #
209
209
  # @api public
210
210
  def after(*hooks)
211
- if !hooks.empty?
212
- set_hooks(:after, hooks)
213
- else
211
+ if hooks.empty?
214
212
  @after
213
+ else
214
+ set_hooks(:after, hooks)
215
215
  end
216
216
  end
217
217
 
@@ -252,16 +252,16 @@ module ROM
252
252
  def relation_methods_mod(relation_class)
253
253
  Module.new do
254
254
  relation_class.view_methods.each do |meth|
255
- module_eval <<-RUBY, __FILE__, __LINE__ + 1
256
- def #{meth}(*args)
257
- response = relation.public_send(:#{meth}, *args)
258
-
259
- if response.is_a?(relation.class)
260
- new(response)
261
- else
262
- response
263
- end
264
- end
255
+ module_eval(<<-RUBY, __FILE__, __LINE__ + 1)
256
+ def #{meth}(*args, **kwargs) # def create(*args, **kwargs)
257
+ response = relation.public_send(:#{meth}, *args, **kwargs) # response = relation.public_send(:create, *args, **kwargs)
258
+ #
259
+ if response.is_a?(relation.class) # if response.is_a?(relation.class)
260
+ new(response) # new(response)
261
+ else # else
262
+ response # response
263
+ end # end
264
+ end # end
265
265
  RUBY
266
266
  end
267
267
  end
@@ -15,6 +15,8 @@ module ROM
15
15
  # @return [Object]
16
16
  #
17
17
  # @api public
18
+ #
19
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
18
20
  def call(*args)
19
21
  response = left.call(*args)
20
22
 
@@ -35,6 +37,7 @@ module ROM
35
37
  end
36
38
  end
37
39
  alias_method :[], :call
40
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
38
41
 
39
42
  # @api private
40
43
  def graph?
@@ -25,6 +25,7 @@ module ROM
25
25
  end
26
26
 
27
27
  # @api private
28
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
28
29
  def build_command(registry, spec, other, path)
29
30
  cmd_opts, nodes = other
30
31
 
@@ -43,7 +44,7 @@ module ROM
43
44
  end
44
45
 
45
46
  command = registry[relation][name]
46
- tuple_path = Array[*path] << key
47
+ tuple_path = [*path] << key
47
48
  input_proc = InputEvaluator.build(tuple_path, nodes)
48
49
 
49
50
  command = command.curry(input_proc, opts)
@@ -58,6 +59,7 @@ module ROM
58
59
  command
59
60
  end
60
61
  end
62
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
61
63
  end
62
64
  end
63
65
  end
@@ -48,7 +48,7 @@ module ROM
48
48
  #
49
49
  # @api private
50
50
  def self.exclude_proc(excluded_keys)
51
- -> input { input.reject { |k, _| excluded_keys.include?(k) } }
51
+ -> input { input.except(*excluded_keys) }
52
52
  end
53
53
 
54
54
  # Initialize a new input evaluator
@@ -68,6 +68,7 @@ module ROM
68
68
  # @param [Integer] index Optional index
69
69
  #
70
70
  # @return [Hash]
71
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
71
72
  def call(input, index = nil)
72
73
  value =
73
74
  begin
@@ -88,6 +89,7 @@ module ROM
88
89
  value
89
90
  end
90
91
  end
92
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
91
93
  end
92
94
  end
93
95
  end
@@ -49,6 +49,8 @@ module ROM
49
49
  # @return [Array] nested array with command results
50
50
  #
51
51
  # @api public
52
+ #
53
+ # rubocop:disable Metrics/PerceivedComplexity
52
54
  def call(*args)
53
55
  left = root.call(*args)
54
56
 
@@ -73,6 +75,7 @@ module ROM
73
75
  [left, right]
74
76
  end
75
77
  end
78
+ # rubocop:enable Metrics/PerceivedComplexity
76
79
 
77
80
  # @api private
78
81
  def graph?
@@ -14,6 +14,7 @@ module ROM
14
14
  # @return [Hash,Array<Hash>]
15
15
  #
16
16
  # @api public
17
+ # rubocop:disable Metrics/AbcSize
17
18
  def call(*args)
18
19
  first = args.first
19
20
  last = args.last
@@ -29,6 +30,7 @@ module ROM
29
30
  command.call(input, *args[1..size - 1])
30
31
  end
31
32
  end
33
+ # rubocop:enable Metrics/AbcSize
32
34
  end
33
35
  end
34
36
  end
@@ -14,6 +14,7 @@ module ROM
14
14
  # @return [Hash, Array<Hash>]
15
15
  #
16
16
  # @api public
17
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
17
18
  def call(*args)
18
19
  first = args.first
19
20
  last = args.last
@@ -40,6 +41,7 @@ module ROM
40
41
  end
41
42
  end
42
43
  end
44
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
43
45
  end
44
46
  end
45
47
  end
@@ -83,9 +83,9 @@ module ROM
83
83
  private
84
84
 
85
85
  # @api private
86
- def method_missing(name, *args, &block)
86
+ def method_missing(name, ...)
87
87
  if command.respond_to?(name)
88
- response = command.public_send(name, *args, &block)
88
+ response = command.public_send(name, ...)
89
89
 
90
90
  if response.instance_of?(command.class)
91
91
  self.class.new(response, evaluator, command_proc)
@@ -96,7 +96,6 @@ module ROM
96
96
  super
97
97
  end
98
98
  end
99
- ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
100
99
  end
101
100
  end
102
101
  end
@@ -20,9 +20,9 @@ module ROM
20
20
  register_event('configuration.relations.dataset.allocated')
21
21
  register_event('configuration.commands.class.before_build')
22
22
 
23
- include ROM::ConfigurationDSL
23
+ include ::ROM::ConfigurationDSL
24
24
 
25
- NoDefaultAdapterError = Class.new(StandardError)
25
+ NoDefaultAdapterError = ::Class.new(::StandardError)
26
26
 
27
27
  # @!attribute [r] environment
28
28
  # @return [Environment] Environment object with gateways
@@ -36,7 +36,8 @@ module ROM
36
36
  # @return [Notifications] Notification bus instance
37
37
  attr_reader :notifications
38
38
 
39
- def_delegators :@setup, :register_relation, :register_command, :register_mapper, :register_plugin,
39
+ def_delegators :@setup, :register_relation, :register_command,
40
+ :register_mapper, :register_plugin,
40
41
  :command_classes, :mapper_classes,
41
42
  :auto_registration
42
43
 
@@ -49,12 +50,12 @@ module ROM
49
50
  # @return [Configuration]
50
51
  #
51
52
  # @api private
52
- def initialize(*args, &block)
53
+ def initialize(*args, &)
53
54
  @environment = Environment.new(*args)
54
55
  @notifications = Notifications.event_bus(:configuration)
55
56
  @setup = Setup.new(notifications)
56
57
 
57
- block&.call(self)
58
+ yield self if block_given?
58
59
  end
59
60
 
60
61
  # Apply a plugin to the configuration
@@ -66,9 +67,9 @@ module ROM
66
67
  #
67
68
  # @api public
68
69
  def use(plugin, options = {})
69
- if plugin.is_a?(Array)
70
+ if plugin.is_a?(::Array)
70
71
  plugin.each { |p| use(p) }
71
- elsif plugin.is_a?(Hash)
72
+ elsif plugin.is_a?(::Hash)
72
73
  plugin.to_a.each { |p| use(*p) }
73
74
  else
74
75
  ROM.plugin_registry[:configuration].fetch(plugin).apply_to(self, options)
@@ -82,16 +83,12 @@ module ROM
82
83
  # @return [Gateway]
83
84
  #
84
85
  # @api private
85
- def [](name)
86
- gateways.fetch(name)
87
- end
86
+ def [](name) = gateways.fetch(name)
88
87
 
89
88
  # Hook for respond_to? used internally
90
89
  #
91
90
  # @api private
92
- def respond_to?(name, include_all = false)
93
- gateways.key?(name) || super
94
- end
91
+ def respond_to?(name, ...) = gateways.key?(name) || super
95
92
 
96
93
  # @api private
97
94
  def default_gateway
@@ -122,13 +119,14 @@ module ROM
122
119
 
123
120
  private
124
121
 
122
+ # @api private
123
+ def respond_to_missing?(name, ...) = gateways.key?(name) || super
124
+
125
125
  # Returns gateway if method is a name of a registered gateway
126
126
  #
127
127
  # @return [Gateway]
128
128
  #
129
129
  # @api private
130
- def method_missing(name, *)
131
- gateways.fetch(name) { super }
132
- end
130
+ def method_missing(name, ...) = gateways.fetch(name) { super }
133
131
  end
134
132
  end
@@ -13,7 +13,7 @@ module ROM
13
13
  # This is used by Setup#commands DSL and its `define` block
14
14
  #
15
15
  # @api private
16
- def self.build_class(name, relation, options = EMPTY_HASH, &block)
16
+ def self.build_class(name, relation, options = EMPTY_HASH, &)
17
17
  type = options.fetch(:type) { name }
18
18
  command_type = Inflector.classify(type)
19
19
  adapter = options.fetch(:adapter)
@@ -23,7 +23,7 @@ module ROM
23
23
  Dry::Core::ClassBuilder.new(name: class_name, parent: parent).call do |klass|
24
24
  klass.register_as(name)
25
25
  klass.relation(relation)
26
- klass.class_eval(&block) if block
26
+ klass.class_eval(&) if block_given?
27
27
  end
28
28
  end
29
29
 
@@ -8,14 +8,18 @@ module ROM
8
8
  #
9
9
  # @private
10
10
  class CommandDSL
11
- attr_reader :relation, :adapter, :command_classes
11
+ attr_reader :relation
12
+
13
+ attr_reader :adapter
14
+
15
+ attr_reader :command_classes
12
16
 
13
17
  # @api private
14
- def initialize(relation, adapter = nil, &block)
18
+ def initialize(relation, adapter = nil, &)
15
19
  @relation = relation
16
20
  @adapter = adapter
17
21
  @command_classes = []
18
- instance_exec(&block)
22
+ instance_exec(&)
19
23
  end
20
24
 
21
25
  # Define a command class
@@ -27,9 +31,9 @@ module ROM
27
31
  # @return [Class] generated class
28
32
  #
29
33
  # @api public
30
- def define(name, options = EMPTY_HASH, &block)
34
+ def define(name, options = EMPTY_HASH, &)
31
35
  @command_classes << Command.build_class(
32
- name, relation, { adapter: adapter }.merge(options), &block
36
+ name, relation, { adapter: adapter }.merge(options), &
33
37
  )
34
38
  end
35
39
  end
@@ -8,7 +8,11 @@ module ROM
8
8
  #
9
9
  # @private
10
10
  class MapperDSL
11
- attr_reader :configuration, :mapper_classes, :defined_mappers
11
+ attr_reader :configuration
12
+
13
+ attr_reader :mapper_classes
14
+
15
+ attr_reader :defined_mappers
12
16
 
13
17
  # @api private
14
18
  def initialize(configuration, mapper_classes, block)
@@ -29,8 +33,13 @@ module ROM
29
33
  # @return [Class]
30
34
  #
31
35
  # @api public
32
- def define(name, options = EMPTY_HASH, &block)
33
- @defined_mappers << Mapper::Builder.build_class(name, (@mapper_classes + @defined_mappers), options, &block)
36
+ def define(name, options = EMPTY_HASH, &)
37
+ @defined_mappers << Mapper::Builder.build_class(
38
+ name,
39
+ @mapper_classes + @defined_mappers,
40
+ options,
41
+ &
42
+ )
34
43
  self
35
44
  end
36
45
 
@@ -17,9 +17,11 @@ module ROM
17
17
  class_name = "ROM::Relation[#{Inflector.camelize(name)}]"
18
18
  adapter = options.fetch(:adapter)
19
19
 
20
- Dry::Core::ClassBuilder.new(name: class_name, parent: ROM::Relation[adapter]).call do |klass|
20
+ ::Dry::Core::ClassBuilder.new(
21
+ name: class_name, parent: ::ROM::Relation[adapter]
22
+ ).call do |klass|
21
23
  klass.gateway(options.fetch(:gateway, :default))
22
- klass.schema(name) {}
24
+ klass.schema(name) { nil }
23
25
  end
24
26
  end
25
27
  end
@@ -19,11 +19,11 @@ module ROM
19
19
  # end
20
20
  #
21
21
  # @api public
22
- def relation(name, options = EMPTY_HASH, &block)
22
+ def relation(name, options = EMPTY_HASH, &)
23
23
  klass_opts = { adapter: default_adapter }.merge(options)
24
24
  klass = Relation.build_class(name, klass_opts)
25
25
  klass.schema_opts(dataset: name, relation: name)
26
- klass.class_eval(&block) if block
26
+ klass.class_eval(&) if block_given?
27
27
  register_relation(klass)
28
28
  klass
29
29
  end
@@ -48,8 +48,8 @@ module ROM
48
48
  # end
49
49
  #
50
50
  # @api public
51
- def commands(name, &block)
52
- register_command(*CommandDSL.new(name, default_adapter, &block).command_classes)
51
+ def commands(name, &)
52
+ register_command(*CommandDSL.new(name, default_adapter, &).command_classes)
53
53
  end
54
54
 
55
55
  # Mapper definition DSL
@@ -76,22 +76,20 @@ module ROM
76
76
  # @return [Plugin]
77
77
  #
78
78
  # @api public
79
- def plugin(adapter, spec, &block)
79
+ def plugin(adapter, spec, &)
80
80
  type, name = spec.flatten(1)
81
81
  plugin = plugin_registry[type].adapter(adapter).fetch(name) do
82
82
  plugin_registry[type].fetch(name)
83
83
  end
84
84
 
85
- if block
86
- register_plugin(plugin.configure(&block))
85
+ if block_given?
86
+ register_plugin(plugin.configure(&))
87
87
  else
88
88
  register_plugin(plugin)
89
89
  end
90
90
  end
91
91
 
92
92
  # @api private
93
- def plugin_registry
94
- ROM.plugin_registry
95
- end
93
+ def plugin_registry = ::ROM.plugin_registry
96
94
  end
97
95
  end
data/lib/rom/constants.rb CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  # Constants and errors common in the whole library
4
4
  module ROM
5
- include Dry::Core::Constants
5
+ include ::Dry::Core::Constants
6
6
 
7
- AdapterLoadError = Class.new(StandardError)
7
+ AdapterLoadError = ::Class.new(::StandardError)
8
8
 
9
9
  # Exception raised when a component is configured with an adapter that's not loaded
10
- class AdapterNotPresentError < StandardError
10
+ class AdapterNotPresentError < ::StandardError
11
11
  # @api private
12
12
  def initialize(adapter, component)
13
13
  super(
@@ -17,22 +17,22 @@ module ROM
17
17
  end
18
18
  end
19
19
 
20
- EnvAlreadyFinalizedError = Class.new(StandardError)
21
- RelationAlreadyDefinedError = Class.new(StandardError)
22
- MapperAlreadyDefinedError = Class.new(StandardError)
23
- MapperMisconfiguredError = Class.new(StandardError)
24
- NoRelationError = Class.new(StandardError)
25
- InvalidRelationName = Class.new(StandardError)
26
- CommandError = Class.new(StandardError)
27
- KeyMissing = Class.new(ROM::CommandError)
28
- TupleCountMismatchError = Class.new(CommandError)
29
- UnknownPluginError = Class.new(StandardError)
30
- UnsupportedRelationError = Class.new(StandardError)
31
- MissingAdapterIdentifierError = Class.new(StandardError)
32
- AttributeAlreadyDefinedError = Class.new(StandardError)
20
+ EnvAlreadyFinalizedError = ::Class.new(::StandardError)
21
+ RelationAlreadyDefinedError = ::Class.new(::StandardError)
22
+ MapperAlreadyDefinedError = ::Class.new(::StandardError)
23
+ MapperMisconfiguredError = ::Class.new(::StandardError)
24
+ NoRelationError = ::Class.new(::StandardError)
25
+ InvalidRelationName = ::Class.new(::StandardError)
26
+ CommandError = ::Class.new(::StandardError)
27
+ KeyMissing = ::Class.new(::ROM::CommandError)
28
+ TupleCountMismatchError = ::Class.new(::ROM::CommandError)
29
+ UnknownPluginError = ::Class.new(::StandardError)
30
+ UnsupportedRelationError = ::Class.new(::StandardError)
31
+ MissingAdapterIdentifierError = ::Class.new(::StandardError)
32
+ AttributeAlreadyDefinedError = ::Class.new(::StandardError)
33
33
 
34
34
  # Exception raised when a reserved keyword is used as a relation name
35
- class InvalidRelationName < StandardError
35
+ class InvalidRelationName < ::StandardError
36
36
  # @api private
37
37
  def initialize(relation)
38
38
  super("Relation name: #{relation} is a protected word, please use another relation name")
@@ -40,7 +40,7 @@ module ROM
40
40
  end
41
41
 
42
42
  # Exception raised when an element inside a component registry is not found
43
- class ElementNotFoundError < KeyError
43
+ class ElementNotFoundError < ::KeyError
44
44
  # @api private
45
45
  def initialize(key, registry)
46
46
  super(set_message(key, registry))
@@ -52,32 +52,32 @@ module ROM
52
52
  end
53
53
  end
54
54
 
55
- MapperMissingError = Class.new(ElementNotFoundError)
55
+ MapperMissingError = ::Class.new(ElementNotFoundError)
56
56
 
57
- CommandNotFoundError = Class.new(ElementNotFoundError) do
57
+ CommandNotFoundError = ::Class.new(ElementNotFoundError) do
58
58
  # @api private
59
59
  def set_message(key, registry)
60
60
  "There is no :#{key} command for :#{registry.relation_name} relation"
61
61
  end
62
62
  end
63
63
 
64
- MissingSchemaClassError = Class.new(StandardError) do
64
+ MissingSchemaClassError = ::Class.new(::StandardError) do
65
65
  # @api private
66
66
  def initialize(klass)
67
67
  super("#{klass.inspect} relation is missing schema_class")
68
68
  end
69
69
  end
70
70
 
71
- MissingSchemaError = Class.new(StandardError) do
71
+ MissingSchemaError = ::Class.new(::StandardError) do
72
72
  # @api private
73
73
  def initialize(klass)
74
74
  super("#{klass.inspect} relation is missing schema definition")
75
75
  end
76
76
  end
77
77
 
78
- DuplicateConfigurationError = Class.new(StandardError)
79
- DuplicateContainerError = Class.new(StandardError)
78
+ DuplicateConfigurationError = ::Class.new(::StandardError)
79
+ DuplicateContainerError = ::Class.new(::StandardError)
80
80
 
81
- InvalidOptionValueError = Class.new(StandardError)
82
- InvalidOptionKeyError = Class.new(StandardError)
81
+ InvalidOptionValueError = ::Class.new(::StandardError)
82
+ InvalidOptionKeyError = ::Class.new(::StandardError)
83
83
  end
data/lib/rom/container.rb CHANGED
@@ -110,41 +110,43 @@ module ROM
110
110
  end
111
111
  end
112
112
 
113
+ # @api private
114
+ attr_reader :cache
115
+
116
+ # @api private
117
+ def initialize
118
+ super
119
+
120
+ @cache = Cache.new
121
+ end
122
+
113
123
  # Return registered gateways
114
124
  #
115
125
  # @return [Hash<Symbol=>Gateway>]
116
126
  #
117
127
  # @api public
118
- def gateways
119
- self[:gateways]
120
- end
128
+ def gateways = self[:gateways]
121
129
 
122
130
  # Return mapper registry for all relations
123
131
  #
124
132
  # @return [Hash<Symbol=>MapperRegistry]
125
133
  #
126
134
  # @api public
127
- def mappers
128
- self[:mappers]
129
- end
135
+ def mappers = self[:mappers]
130
136
 
131
137
  # Return relation registry
132
138
  #
133
139
  # @return [RelationRegistry]
134
140
  #
135
141
  # @api public
136
- def relations
137
- self[:relations]
138
- end
142
+ def relations = self[:relations]
139
143
 
140
144
  # Return command registry
141
145
  #
142
146
  # @return [Hash<Symbol=>CommandRegistry]
143
147
  #
144
148
  # @api public
145
- def commands
146
- self[:commands]
147
- end
149
+ def commands = self[:commands]
148
150
 
149
151
  # Disconnect all gateways
150
152
  #
@@ -156,8 +158,6 @@ module ROM
156
158
  # @return [Hash<Symbol=>Gateway>] a hash with disconnected gateways
157
159
  #
158
160
  # @api public
159
- def disconnect
160
- gateways.each_value(&:disconnect)
161
- end
161
+ def disconnect = gateways.each_value(&:disconnect)
162
162
  end
163
163
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ROM
4
4
  module Core
5
- VERSION = '5.3.2'
5
+ VERSION = '5.4.0'
6
6
  end
7
7
  end
data/lib/rom/core.rb CHANGED
@@ -28,7 +28,6 @@ require 'rom/container'
28
28
  require 'rom/create_container'
29
29
 
30
30
  # register known plugin types
31
- require 'rom/schema_plugin'
32
31
 
33
32
  ROM::Plugins.register(:command)
34
33
  ROM::Plugins.register(:mapper)
@@ -44,7 +44,7 @@ module ROM
44
44
  # @api private
45
45
  class InlineCreateContainer < CreateContainer
46
46
  # @api private
47
- def initialize(*args, &block)
47
+ def initialize(*args, &)
48
48
  case args.first
49
49
  when Configuration
50
50
  environment = args.first.environment
@@ -53,7 +53,7 @@ module ROM
53
53
  environment = args.first
54
54
  setup = args[1]
55
55
  else
56
- configuration = Configuration.new(*args, &block)
56
+ configuration = Configuration.new(*args, &)
57
57
  environment = configuration.environment
58
58
  setup = configuration.setup
59
59
  end
@@ -63,7 +63,5 @@ module ROM
63
63
  end
64
64
 
65
65
  # @api private
66
- def self.container(*args, &block)
67
- InlineCreateContainer.new(*args, &block).container
68
- end
66
+ def self.container(...) = InlineCreateContainer.new(...).container
69
67
  end