1
1
# frozen_string_literal: true
2
2
3
- require 'transproc /all'
3
+ require 'dry/transformer /all'
4
4
5
5
require 'rom/processor'
6
+ require 'rom/processor/composer'
6
7
7
8
module ROM
8
9
class Processor
9
- # Data mapping transformer builder using Transproc
10
+ # Data mapping transformer builder using dry-transformer
10
11
#
11
- # This builds a transproc function that is used to map a whole relation
12
+ # This builds a transformer object that is used to map a whole relation
12
13
#
13
- # @see https://github.com/solnic/transproc too
14
+ # @see https://github.com/dry-rb/dry-transformer
14
15
#
15
16
# @private
16
- class Transproc < Processor
17
- include :: Transproc :: Composer
17
+ class Transformer < Processor
18
+ include Composer
18
19
19
20
module Functions
20
- extend ::Transproc ::Registry
21
+ extend Dry ::Transformer ::Registry
22
+
23
+ import Dry ::Transformer ::Coercions
24
+ import Dry ::Transformer ::ArrayTransformations
25
+ import Dry ::Transformer ::HashTransformations
26
+ import Dry ::Transformer ::ClassTransformations
27
+ import Dry ::Transformer ::ProcTransformations
21
28
22
- import ::Transproc ::Coercions
23
- import ::Transproc ::ArrayTransformations
24
- import ::Transproc ::HashTransformations
25
- import ::Transproc ::ClassTransformations
26
- import ::Transproc ::ProcTransformations
27
29
INVALID_INJECT_UNION_VALUE = "%s attribute: block is required for :from with union value." . freeze
28
30
29
31
def self . identity ( tuple )
@@ -73,15 +75,15 @@ def self.inject_union_value(tuple, name, keys, coercer)
73
75
# @api private
74
76
attr_reader :row_proc
75
77
76
- # Build a transproc function from the header
78
+ # Build a transformer object from the header
77
79
#
78
80
# @param [ROM::Header] header
79
81
#
80
- # @return [Transproc::Function ]
82
+ # @return [Dry::Transformer::Pipe ]
81
83
#
82
84
# @api private
83
85
def self . build ( mapper , header )
84
- new ( mapper , header ) . to_transproc
86
+ new ( mapper , header ) . call
85
87
end
86
88
87
89
# @api private
@@ -93,12 +95,12 @@ def initialize(mapper, header)
93
95
initialize_row_proc
94
96
end
95
97
96
- # Coerce mapper header to a transproc data mapping function
98
+ # Coerce mapper header to a transformer object
97
99
#
98
- # @return [Transproc::Function ]
100
+ # @return [Dry::Transformer::Pipe ]
99
101
#
100
102
# @api private
101
- def to_transproc
103
+ def call
102
104
compose ( t ( :identity ) ) do |ops |
103
105
combined = header . combined
104
106
ops << t ( :combine , combined . map ( &method ( :combined_args ) ) ) if combined . any?
0 commit comments