rom-core 5.3.1 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +17 -20
  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
data/lib/rom/mapper.rb CHANGED
@@ -9,7 +9,7 @@ module ROM
9
9
  # @private
10
10
  class Mapper
11
11
  include DSL
12
- include Dry::Equalizer(:transformers, :header)
12
+ include ::Dry::Equalizer(:transformers, :header)
13
13
 
14
14
  defines :relation, :register_as, :symbolize_keys, :copy_keys,
15
15
  :prefix, :prefix_separator, :inherit_header, :reject_keys
@@ -86,9 +86,7 @@ module ROM
86
86
  # @return [Class] optional model that is instantiated by a mapper
87
87
  #
88
88
  # @api private
89
- def model
90
- header.model
91
- end
89
+ def model = header.model
92
90
 
93
91
  # Process a relation using the transformers
94
92
  #
@@ -23,13 +23,12 @@ module ROM
23
23
 
24
24
  attr_reader :mapper_options
25
25
 
26
- def initialize(*)
26
+ def initialize(*, **)
27
27
  super
28
28
  @struct_compiler = StructCompiler.new(cache: cache)
29
29
  @cache = cache.namespaced(:mappers)
30
30
  @mapper_options = self.class.mapper_options
31
31
  end
32
- ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
33
32
 
34
33
  def call(ast)
35
34
  cache.fetch_or_store(ast.hash) { Mapper.build(Header.coerce(*visit(ast))) }
@@ -43,6 +42,7 @@ module ROM
43
42
  __send__("visit_#{name}", node)
44
43
  end
45
44
 
45
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
46
46
  def visit_relation(node)
47
47
  rel_name, header, meta_options = node
48
48
  name = meta_options[:combine_name] || meta_options[:alias] || rel_name
@@ -69,6 +69,7 @@ module ROM
69
69
  options
70
70
  end
71
71
  end
72
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
72
73
 
73
74
  def visit_attribute(node)
74
75
  name, _, meta_options = node
@@ -8,9 +8,7 @@ module ROM
8
8
  # @private
9
9
  class MapperRegistry < Registry
10
10
  # @api private
11
- def self.element_not_found_error
12
- MapperMissingError
13
- end
11
+ def self.element_not_found_error = MapperMissingError
14
12
 
15
13
  # @!attribute [r] compiler
16
14
  # @return [MapperCompiler] A mapper compiler instance
@@ -21,7 +19,7 @@ module ROM
21
19
  # @see Registry
22
20
  # @api public
23
21
  def [](*args)
24
- if args[0].is_a?(Symbol)
22
+ if args[0].is_a?(::Symbol)
25
23
  super
26
24
  else
27
25
  cache.fetch_or_store(args.hash) { compiler.(*args) }
@@ -17,7 +17,7 @@ module ROM
17
17
 
18
18
  # @see ROM::Commands::Create#execute
19
19
  def execute(tuples)
20
- Array([tuples]).flatten.map { |tuple|
20
+ [tuples].flatten.map { |tuple|
21
21
  attributes = input[tuple]
22
22
  relation.insert(attributes.to_h)
23
23
  attributes
@@ -19,11 +19,12 @@ module ROM
19
19
  # @return [Dataset]
20
20
  #
21
21
  # @api public
22
+ # rubocop:disable Metrics/AbcSize
22
23
  def join(*args)
23
24
  left, right = args.size > 1 ? args : [self, args.first]
24
25
 
25
26
  join_map = left.each_with_object({}) { |tuple, h|
26
- others = right.to_a.find_all { |t| (tuple.to_a & t.to_a).any? }
27
+ others = right.to_a.find_all { |t| tuple.to_a.intersect?(t.to_a) }
27
28
  (h[tuple] ||= []).concat(others)
28
29
  }
29
30
 
@@ -33,6 +34,7 @@ module ROM
33
34
 
34
35
  self.class.new(tuples, **options)
35
36
  end
37
+ # rubocop:enable Metrics/AbcSize
36
38
 
37
39
  # Restrict a dataset
38
40
  #
@@ -41,14 +43,14 @@ module ROM
41
43
  # @return [Dataset]
42
44
  #
43
45
  # @api public
44
- def restrict(criteria = nil)
45
- return find_all { |tuple| yield(tuple) } unless criteria
46
+ def restrict(criteria = nil, &)
47
+ return find_all(&) unless criteria
46
48
 
47
49
  find_all do |tuple|
48
50
  criteria.all? do |k, v|
49
51
  case v
50
- when Array then v.include?(tuple[k])
51
- when Regexp then tuple[k].match(v)
52
+ when ::Array then v.include?(tuple[k])
53
+ when ::Regexp then tuple[k].match(v)
52
54
  else tuple[k].eql?(v)
53
55
  end
54
56
  end
@@ -24,6 +24,7 @@ module ROM
24
24
 
25
25
  # @api private
26
26
  def initialize
27
+ super
27
28
  @connection = Storage.new
28
29
  end
29
30
 
@@ -19,7 +19,11 @@ module ROM
19
19
  class ModelBuilder
20
20
  attr_reader :name
21
21
 
22
- attr_reader :const_name, :namespace, :klass
22
+ attr_reader :const_name
23
+
24
+ attr_reader :namespace
25
+
26
+ attr_reader :klass
23
27
 
24
28
  # Return model builder subclass based on type
25
29
  #
@@ -32,7 +36,7 @@ module ROM
32
36
  case type
33
37
  when :poro then PORO
34
38
  else
35
- raise ArgumentError, "#{type.inspect} is not a supported model type"
39
+ raise ::ArgumentError, "#{type.inspect} is not a supported model type"
36
40
  end
37
41
  end
38
42
 
@@ -41,9 +45,7 @@ module ROM
41
45
  # @return [Class]
42
46
  #
43
47
  # @api private
44
- def self.call(*args)
45
- new(*args).call
46
- end
48
+ def self.call(*args) = new(*args).call
47
49
 
48
50
  # @api private
49
51
  def initialize(options = {})
@@ -66,9 +68,7 @@ module ROM
66
68
  # Define a model class constant
67
69
  #
68
70
  # @api private
69
- def define_const
70
- namespace.const_set(const_name, klass)
71
- end
71
+ def define_const = namespace.const_set(const_name, klass)
72
72
 
73
73
  # Build a model class supporting specific attributes
74
74
  #
@@ -86,14 +86,14 @@ module ROM
86
86
  # @private
87
87
  class PORO < ModelBuilder
88
88
  def define_class(attrs)
89
- @klass = Class.new
89
+ @klass = ::Class.new
90
90
 
91
- @klass.send(:attr_reader, *attrs)
91
+ @klass.attr_reader(*attrs)
92
92
 
93
- @klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
94
- def initialize(params)
95
- #{attrs.map { |name| "@#{name} = params[:#{name}]" }.join("\n")}
96
- end
93
+ @klass.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
94
+ def initialize(params) # def initialize(params)
95
+ #{attrs.map { |name| "@#{name} = params[:#{name}]" }.join("\n")} # @name = params[:name]
96
+ end # end
97
97
  RUBY
98
98
 
99
99
  self
@@ -24,7 +24,7 @@ module ROM
24
24
  private
25
25
 
26
26
  # @api private
27
- def method_missing(meth, *args, &block)
27
+ def method_missing(meth, *args, &)
28
28
  ivar = IVAR[meth]
29
29
 
30
30
  if instance_variables.include?(ivar)
data/lib/rom/pipeline.rb CHANGED
@@ -19,16 +19,12 @@ module ROM
19
19
  # @return [Relation::Composite]
20
20
  #
21
21
  # @api public
22
- def >>(other)
23
- composite_class.new(self, other)
24
- end
22
+ def >>(other) = composite_class.new(self, other)
25
23
 
26
24
  private
27
25
 
28
26
  # @api private
29
- def composite_class
30
- raise NotImplementedError
31
- end
27
+ def composite_class = raise ::NotImplementedError
32
28
  end
33
29
 
34
30
  include Operator
@@ -57,14 +53,12 @@ module ROM
57
53
  # Check if response from method missing should be decorated
58
54
  #
59
55
  # @api private
60
- def decorate?(response)
61
- response.is_a?(left.class)
62
- end
56
+ def decorate?(response) = response.is_a?(left.class)
63
57
 
64
58
  # @api private
65
- def method_missing(name, *args, &block)
59
+ def method_missing(name, ...)
66
60
  if left.respond_to?(name)
67
- response = left.__send__(name, *args, &block)
61
+ response = left.__send__(name, ...)
68
62
 
69
63
  if decorate?(response)
70
64
  self.class.new(response, right)
@@ -75,18 +69,23 @@ module ROM
75
69
  super
76
70
  end
77
71
  end
78
- ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
79
72
  end
80
73
 
81
74
  # Base composite class with left-to-right pipeline behavior
82
75
  #
83
76
  # @api private
84
- class Composite
85
- (Kernel.private_instance_methods - %i[respond_to_missing? block_given?])
86
- .each(&method(:undef_method))
77
+ class Composite < ::BasicObject
78
+ %i[block_given? respond_to_missing?].each do |method|
79
+ define_method(method, ::Kernel.instance_method(method))
80
+ private method
81
+ end
87
82
 
88
- include Dry::Equalizer(:left, :right)
89
- include Proxy
83
+ %i[class to_s inspect is_a? instance_of? to_enum].each do |method|
84
+ define_method(method, ::Kernel.instance_method(method))
85
+ end
86
+
87
+ include ::Dry::Equalizer(:left, :right)
88
+ include ::ROM::Pipeline::Proxy
90
89
 
91
90
  # @api private
92
91
  attr_reader :left
@@ -103,9 +102,7 @@ module ROM
103
102
  # Compose this composite with another object
104
103
  #
105
104
  # @api public
106
- def >>(other)
107
- self.class.new(self, other)
108
- end
105
+ def >>(other) = self.class.new(self, other)
109
106
  end
110
107
  end
111
108
  end
@@ -42,9 +42,7 @@ module ROM
42
42
  end
43
43
 
44
44
  # @api private
45
- def [](type)
46
- types.fetch(singularize(type))
47
- end
45
+ def [](type) = types.fetch(singularize(type))
48
46
 
49
47
  # Old API compatibility
50
48
  #
@@ -64,7 +62,7 @@ module ROM
64
62
  #
65
63
  # @api private
66
64
  class PluginsContainer < Registry
67
- include Dry::Equalizer(:elements, :type)
65
+ include ::Dry::Equalizer(:elements, :type)
68
66
 
69
67
  # @!attribute [r] plugin_type
70
68
  # @return [Class] Typically ROM::PluginBase or its descendant
@@ -82,9 +80,7 @@ module ROM
82
80
  end
83
81
 
84
82
  # @api private
85
- def plugin_type
86
- Plugins[type][:plugin_type]
87
- end
83
+ def plugin_type = Plugins[type][:plugin_type]
88
84
  end
89
85
 
90
86
  # Store a set of registries grouped by adapter
@@ -114,9 +110,7 @@ module ROM
114
110
  # @return [AdapterRegistry]
115
111
  #
116
112
  # @api private
117
- def adapter(name)
118
- registries[name]
119
- end
113
+ def adapter(name) = registries[name]
120
114
 
121
115
  # @api private
122
116
  def register(name, mod, options)
@@ -22,16 +22,20 @@ module ROM
22
22
  # result[:created_at] #=> Time.now.utc
23
23
  #
24
24
  # @api public
25
- class Timestamps < Module
26
- attr_reader :timestamps, :datestamps
25
+ class Timestamps < ::Module
26
+ attr_reader :timestamps
27
+
28
+ attr_reader :datestamps
29
+
27
30
  def initialize(timestamps: [], datestamps: [])
31
+ super()
28
32
  @timestamps = store_attributes(timestamps)
29
33
  @datestamps = store_attributes(datestamps)
30
34
  end
31
35
 
32
36
  # @api private
33
37
  def store_attributes(attr)
34
- attr.is_a?(Array) ? attr : Array[attr]
38
+ attr.is_a?(Array) ? attr : [attr]
35
39
  end
36
40
 
37
41
  # @api private
@@ -117,7 +121,7 @@ module ROM
117
121
  def timestamps(*names)
118
122
  timestamp_columns timestamp_columns.merge(names)
119
123
  end
120
- alias timestamp timestamps
124
+ alias_method :timestamp, :timestamps
121
125
 
122
126
  # Set up attributes to datestamp when the command is called
123
127
  #
@@ -139,7 +143,7 @@ module ROM
139
143
  def datestamps(*names)
140
144
  datestamp_columns datestamp_columns.merge(names)
141
145
  end
142
- alias datestamp datestamps
146
+ alias_method :datestamp, :datestamps
143
147
  end
144
148
  end
145
149
  end
@@ -45,8 +45,13 @@ module ROM
45
45
  # Execute a block using instrumentation
46
46
  #
47
47
  # @api public
48
- def instrument(&block)
49
- notifications.instrument(self.class.adapter, name: name.relation, **notification_payload(self), &block)
48
+ def instrument(&)
49
+ notifications.instrument(
50
+ self.class.adapter,
51
+ name: name.relation,
52
+ **notification_payload(self),
53
+ &
54
+ )
50
55
  end
51
56
 
52
57
  private
@@ -14,12 +14,9 @@ module ROM
14
14
  EMPTY_REGISTRY = RelationRegistry.build(EMPTY_HASH).freeze
15
15
 
16
16
  # @api private
17
- attr_reader :relations
18
-
19
- # @api private
20
- def initialize(relations:)
21
- @relations = relations
22
- define_readers!
17
+ def initialize(readers:)
18
+ super()
19
+ include readers
23
20
  end
24
21
 
25
22
  # @api private
@@ -29,15 +26,6 @@ module ROM
29
26
 
30
27
  klass.option :__registry__, default: -> { EMPTY_REGISTRY }
31
28
  end
32
-
33
- private
34
-
35
- # @api private
36
- def define_readers!
37
- relations.each do |name|
38
- define_method(name) { __registry__[name] }
39
- end
40
- end
41
29
  end
42
30
  end
43
31
  end
data/lib/rom/plugins.rb CHANGED
@@ -11,9 +11,7 @@ module ROM
11
11
 
12
12
  class << self
13
13
  # @api private
14
- def register(entity_type, plugin_type: Plugin, adapter: true)
15
- super(entity_type, plugin_type: plugin_type, adapter: adapter)
16
- end
14
+ def register(entity_type, plugin_type: Plugin, adapter: true) = super
17
15
  end
18
16
  end
19
17
  end
@@ -13,6 +13,7 @@ module ROM
13
13
  # @see https://github.com/solnic/transproc too
14
14
  #
15
15
  # @private
16
+ # rubocop:disable Metrics/ClassLength
16
17
  class Transproc < Processor
17
18
  include ::Transproc::Composer
18
19
 
@@ -84,6 +85,7 @@ module ROM
84
85
 
85
86
  # @api private
86
87
  def initialize(mapper, header)
88
+ super()
87
89
  @mapper = mapper
88
90
  @header = header
89
91
  @model = header.model
@@ -96,6 +98,7 @@ module ROM
96
98
  # @return [Transproc::Function]
97
99
  #
98
100
  # @api private
101
+ # rubocop:disable Metrics/AbcSize
99
102
  def to_transproc
100
103
  compose(t(:identity)) do |ops|
101
104
  combined = header.combined
@@ -105,6 +108,7 @@ module ROM
105
108
  ops << header.postprocessed.map { |attr| visit(attr, true) }
106
109
  end
107
110
  end
111
+ # rubocop:enable Metrics/AbcSize
108
112
 
109
113
  private
110
114
 
@@ -130,6 +134,8 @@ module ROM
130
134
  # @param [Header::Attribute] attribute
131
135
  #
132
136
  # @api private
137
+ #
138
+ # rubocop:disable Metrics/AbcSize
133
139
  def visit_attribute(attribute)
134
140
  coercer = attribute.meta[:coercer]
135
141
  if attribute.union?
@@ -143,6 +149,7 @@ module ROM
143
149
  t(:map_value, attribute.name, t(:"to_#{attribute.type}"))
144
150
  end
145
151
  end
152
+ # rubocop:enable Metrics/AbcSize
146
153
 
147
154
  # Visit hash attribute
148
155
  #
@@ -232,7 +239,7 @@ module ROM
232
239
  # function that is applied to the whole relation
233
240
  #
234
241
  # @api private
235
- def visit_group(attribute, preprocess = false)
242
+ def visit_group(attribute, preprocess = false) # rubocop:disable Style/OptionalBooleanParameter
236
243
  if preprocess
237
244
  name = attribute.name
238
245
  header = attribute.header
@@ -262,7 +269,7 @@ module ROM
262
269
  # function that is applied to the whole relation
263
270
  #
264
271
  # @api private
265
- def visit_ungroup(attribute, preprocess = false)
272
+ def visit_ungroup(attribute, preprocess = false) # rubocop:disable Style/OptionalBooleanParameter
266
273
  if preprocess
267
274
  name = attribute.name
268
275
  header = attribute.header
@@ -290,7 +297,7 @@ module ROM
290
297
  # function that is applied to the whole relation
291
298
  #
292
299
  # @api private
293
- def visit_fold(attribute, preprocess = false)
300
+ def visit_fold(attribute, preprocess = false) # rubocop:disable Style/OptionalBooleanParameter
294
301
  if preprocess
295
302
  name = attribute.name
296
303
  keys = attribute.tuple_keys
@@ -312,7 +319,8 @@ module ROM
312
319
  # function that is applied to the whole relation
313
320
  #
314
321
  # @api private
315
- def visit_unfold(attribute, preprocess = false)
322
+ # rubocop:disable Metrics/AbcSize
323
+ def visit_unfold(attribute, preprocess = false) # rubocop:disable Style/OptionalBooleanParameter
316
324
  return unless preprocess
317
325
 
318
326
  name = attribute.name
@@ -331,6 +339,7 @@ module ROM
331
339
  ops << t(:ungroup, name, [key])
332
340
  end
333
341
  end
342
+ # rubocop:enable Metrics/AbcSize
334
343
 
335
344
  # Visit excluded attribute
336
345
  #
@@ -411,5 +420,6 @@ module ROM
411
420
  Functions[*args]
412
421
  end
413
422
  end
423
+ # rubocop:enable Metrics/ClassLength
414
424
  end
415
425
  end
data/lib/rom/processor.rb CHANGED
@@ -13,6 +13,7 @@ module ROM
13
13
  #
14
14
  # @api private
15
15
  def self.inherited(processor)
16
+ super
16
17
  Mapper.register_processor(processor)
17
18
  end
18
19
 
data/lib/rom/registry.rb CHANGED
@@ -8,10 +8,10 @@ module ROM
8
8
  # @api private
9
9
  class Registry
10
10
  extend Initializer
11
- extend Dry::Core::Cache
11
+ extend ::Dry::Core::Cache
12
12
 
13
- include Enumerable
14
- include Dry::Equalizer(:elements)
13
+ include ::Enumerable
14
+ include ::Dry::Equalizer(:elements)
15
15
 
16
16
  # @!attribute [r] elements
17
17
  # @return [Hash] Internal hash for storing registry objects
@@ -33,9 +33,7 @@ module ROM
33
33
  # Create a registry without options
34
34
  #
35
35
  # @api private
36
- def self.build(elements = {})
37
- new(elements, **{})
38
- end
36
+ def self.build(elements = {}) = new(elements, **{})
39
37
 
40
38
  # @api private
41
39
  def self.[](identifier)
@@ -47,40 +45,37 @@ module ROM
47
45
  end
48
46
 
49
47
  # @api private
50
- def self.element_not_found_error
51
- ElementNotFoundError
52
- end
48
+ def self.element_not_found_error = ElementNotFoundError
53
49
 
54
50
  # @api private
55
- def merge(other)
56
- self.class.new(Hash(other), **options)
57
- end
51
+ def merge(other) = self.class.new(Hash(other), **options)
58
52
 
59
53
  # @api private
60
- def to_hash
61
- elements
62
- end
54
+ def to_hash = elements
63
55
 
64
56
  # @api private
65
- def map
66
- new_elements = elements.each_with_object({}) do |(name, element), h|
67
- h[name] = yield(element)
68
- end
57
+ def map(&)
58
+ new_elements = elements.transform_values(&)
69
59
  self.class.new(new_elements, **options)
70
60
  end
71
61
 
72
62
  # @api private
73
- def each
63
+ def each(&)
74
64
  return to_enum unless block_given?
75
65
 
76
- elements.each { |element| yield(element) }
66
+ elements.each(&)
77
67
  end
78
68
 
79
69
  # @api private
80
- def key?(name)
81
- !name.nil? && elements.key?(name.to_sym)
70
+ def each_value(&)
71
+ return to_enum(:each_value) unless block_given?
72
+
73
+ elements.each_value(&)
82
74
  end
83
75
 
76
+ # @api private
77
+ def key?(name) = !name.nil? && elements.key?(name.to_sym)
78
+
84
79
  # @api private
85
80
  def fetch(key)
86
81
  raise ArgumentError, 'key cannot be nil' if key.nil?
@@ -93,9 +88,7 @@ module ROM
93
88
  end
94
89
  alias_method :[], :fetch
95
90
 
96
- def type
97
- self.class.name
98
- end
91
+ def type = self.class.name
99
92
 
100
93
  # @api private
101
94
  def respond_to_missing?(name, include_private = false)
@@ -105,8 +98,6 @@ module ROM
105
98
  private
106
99
 
107
100
  # @api private
108
- def method_missing(name, *)
109
- elements.fetch(name) { super }
110
- end
101
+ def method_missing(name, *) = elements.fetch(name) { super }
111
102
  end
112
103
  end