rom 0.8.1 → 0.9.0.beta1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -1
- data/lib/rom.rb +35 -16
- data/lib/rom/command.rb +1 -9
- data/lib/rom/commands/graph/class_interface.rb +2 -2
- data/lib/rom/constants.rb +0 -6
- data/lib/rom/{env.rb → container.rb} +3 -3
- data/lib/rom/environment.rb +238 -0
- data/lib/rom/environment_plugin.rb +17 -0
- data/lib/rom/environment_plugins/auto_registration.rb +17 -0
- data/lib/rom/global.rb +0 -203
- data/lib/rom/mapper_registry.rb +2 -0
- data/lib/rom/pipeline.rb +2 -0
- data/lib/rom/plugin.rb +4 -18
- data/lib/rom/plugin_base.rb +31 -0
- data/lib/rom/plugin_registry.rb +54 -17
- data/lib/rom/relation.rb +54 -11
- data/lib/rom/relation/class_interface.rb +14 -21
- data/lib/rom/relation/curried.rb +36 -2
- data/lib/rom/relation/graph.rb +7 -0
- data/lib/rom/relation_registry.rb +4 -0
- data/lib/rom/setup.rb +9 -8
- data/lib/rom/setup/finalize.rb +5 -5
- data/lib/rom/version.rb +1 -1
- data/rom.gemspec +2 -0
- data/spec/integration/commands/create_spec.rb +1 -1
- data/spec/integration/commands/update_spec.rb +1 -1
- data/spec/integration/mappers/unwrap_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/rom/{env_spec.rb → container_spec.rb} +5 -5
- data/spec/unit/rom/plugin_spec.rb +0 -8
- data/spec/unit/rom/relation/composite_spec.rb +2 -2
- data/spec/unit/rom/relation/curried_spec.rb +53 -0
- data/spec/unit/rom/relation/graph_spec.rb +4 -0
- data/spec/unit/rom/relation/lazy/combine_spec.rb +6 -6
- data/spec/unit/rom/relation/lazy_spec.rb +4 -8
- data/spec/unit/rom/relation_spec.rb +0 -14
- data/spec/unit/rom/setup_spec.rb +1 -1
- metadata +52 -35
- data/lib/rom/header.rb +0 -193
- data/lib/rom/header/attribute.rb +0 -184
- data/lib/rom/mapper.rb +0 -103
- data/lib/rom/mapper/attribute_dsl.rb +0 -477
- data/lib/rom/mapper/dsl.rb +0 -119
- data/lib/rom/mapper/model_dsl.rb +0 -55
- data/lib/rom/model_builder.rb +0 -101
- data/lib/rom/processor.rb +0 -28
- data/lib/rom/processor/transproc.rb +0 -388
- data/lib/rom/relation/lazy.rb +0 -145
- data/lib/rom/support/array_dataset.rb +0 -41
- data/lib/rom/support/class_builder.rb +0 -44
- data/lib/rom/support/class_macros.rb +0 -56
- data/lib/rom/support/data_proxy.rb +0 -102
- data/lib/rom/support/deprecations.rb +0 -36
- data/lib/rom/support/enumerable_dataset.rb +0 -65
- data/lib/rom/support/inflector.rb +0 -73
- data/lib/rom/support/options.rb +0 -195
- data/lib/rom/support/registry.rb +0 -43
- data/spec/unit/rom/header_spec.rb +0 -102
- data/spec/unit/rom/mapper/dsl_spec.rb +0 -467
- data/spec/unit/rom/mapper_spec.rb +0 -84
- data/spec/unit/rom/model_builder_spec.rb +0 -46
- data/spec/unit/rom/processor/transproc_spec.rb +0 -448
- data/spec/unit/rom/support/array_dataset_spec.rb +0 -61
- data/spec/unit/rom/support/class_builder_spec.rb +0 -42
- data/spec/unit/rom/support/enumerable_dataset_spec.rb +0 -17
- data/spec/unit/rom/support/inflector_spec.rb +0 -89
- data/spec/unit/rom/support/options_spec.rb +0 -119
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ROM::Relation
|
3
|
+
describe ROM::Relation, '#combine' do
|
4
4
|
include_context 'users and tasks'
|
5
5
|
|
6
6
|
before do
|
@@ -100,8 +100,8 @@ describe ROM::Relation::Lazy, '#combine' do
|
|
100
100
|
{ name: 'Jane', title: 'be cool', priority: 2 }
|
101
101
|
],
|
102
102
|
tags: [
|
103
|
-
{ task: 'be cool', name: 'red'
|
104
|
-
{ task: 'be cool', name: 'green'
|
103
|
+
{ task: 'be cool', name: 'red' },
|
104
|
+
{ task: 'be cool', name: 'green' }
|
105
105
|
]
|
106
106
|
}
|
107
107
|
]
|
@@ -111,7 +111,7 @@ describe ROM::Relation::Lazy, '#combine' do
|
|
111
111
|
|
112
112
|
result = user_with_tasks_and_tags >> map_user_with_tasks_and_tags
|
113
113
|
|
114
|
-
expect(result).to
|
114
|
+
expect(result.to_a).to eql(expected)
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'supports more than one eagerly-loaded relation via chaining' do
|
@@ -123,8 +123,8 @@ describe ROM::Relation::Lazy, '#combine' do
|
|
123
123
|
{ name: 'Jane', title: 'be cool', priority: 2 }
|
124
124
|
],
|
125
125
|
tags: [
|
126
|
-
{ task: 'be cool', name: 'red'
|
127
|
-
{ task: 'be cool', name: 'green'
|
126
|
+
{ task: 'be cool', name: 'red' },
|
127
|
+
{ task: 'be cool', name: 'green' }
|
128
128
|
]
|
129
129
|
}
|
130
130
|
]
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ROM::Relation
|
3
|
+
describe ROM::Relation do
|
4
4
|
include_context 'users and tasks'
|
5
5
|
|
6
|
-
let(:users) { rom.relations.users
|
7
|
-
let(:tasks) { rom.relations.tasks
|
6
|
+
let(:users) { rom.relations.users }
|
7
|
+
let(:tasks) { rom.relations.tasks }
|
8
8
|
|
9
9
|
before do
|
10
10
|
setup.relation(:users) do
|
@@ -108,12 +108,8 @@ describe ROM::Relation::Lazy do
|
|
108
108
|
expect(users.call.to_a).to eql(rom.relations.users.to_a)
|
109
109
|
end
|
110
110
|
|
111
|
-
it 'does not allow currying on already curried relation' do
|
112
|
-
expect { users.by_name.by_email }.to raise_error(NoMethodError, /by_email/)
|
113
|
-
end
|
114
|
-
|
115
111
|
describe 'using mappers' do
|
116
|
-
subject(:users) { rom.relations.users.
|
112
|
+
subject(:users) { rom.relations.users.with(mappers: mappers) }
|
117
113
|
|
118
114
|
let(:name_list) { proc { |r| r.map { |t| t[:name] } } }
|
119
115
|
let(:upcaser) { proc { |r| r.map(&:upcase) } }
|
@@ -29,20 +29,6 @@ describe ROM::Relation do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe '#exposed_relations' do
|
33
|
-
it 'returns exposed relation name' do
|
34
|
-
relation_class = Class.new(ROM::Relation[:memory]) {
|
35
|
-
def foo
|
36
|
-
end
|
37
|
-
|
38
|
-
def bar
|
39
|
-
end
|
40
|
-
}
|
41
|
-
|
42
|
-
expect(relation_class.exposed_relations).to include(:foo, :bar)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
32
|
describe '#name' do
|
47
33
|
before { ROM.setup(:memory) }
|
48
34
|
|
data/spec/unit/rom/setup_spec.rb
CHANGED
@@ -82,7 +82,7 @@ describe ROM::Setup do
|
|
82
82
|
it 'resets boot to nil' do
|
83
83
|
setup = ROM.setup(:memory)
|
84
84
|
|
85
|
-
allow(setup).to receive(:
|
85
|
+
allow(setup).to receive(:container).and_raise(StandardError)
|
86
86
|
|
87
87
|
expect { ROM.finalize }.to raise_error(StandardError)
|
88
88
|
expect(ROM.boot).to be(nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: transproc
|
@@ -50,6 +50,46 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.0.9
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rom-support
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.1.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.1.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rom-mapper
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.2'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.0
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.2.0
|
53
93
|
- !ruby/object:Gem::Dependency
|
54
94
|
name: rake
|
55
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,21 +151,18 @@ files:
|
|
111
151
|
- lib/rom/commands/result.rb
|
112
152
|
- lib/rom/commands/update.rb
|
113
153
|
- lib/rom/constants.rb
|
114
|
-
- lib/rom/
|
154
|
+
- lib/rom/container.rb
|
155
|
+
- lib/rom/environment.rb
|
156
|
+
- lib/rom/environment_plugin.rb
|
157
|
+
- lib/rom/environment_plugins/auto_registration.rb
|
115
158
|
- lib/rom/gateway.rb
|
116
159
|
- lib/rom/global.rb
|
117
160
|
- lib/rom/global/plugin_dsl.rb
|
118
|
-
- lib/rom/header.rb
|
119
|
-
- lib/rom/header/attribute.rb
|
120
161
|
- lib/rom/lint/enumerable_dataset.rb
|
121
162
|
- lib/rom/lint/gateway.rb
|
122
163
|
- lib/rom/lint/linter.rb
|
123
164
|
- lib/rom/lint/spec.rb
|
124
165
|
- lib/rom/lint/test.rb
|
125
|
-
- lib/rom/mapper.rb
|
126
|
-
- lib/rom/mapper/attribute_dsl.rb
|
127
|
-
- lib/rom/mapper/dsl.rb
|
128
|
-
- lib/rom/mapper/model_dsl.rb
|
129
166
|
- lib/rom/mapper_registry.rb
|
130
167
|
- lib/rom/memory.rb
|
131
168
|
- lib/rom/memory/commands.rb
|
@@ -133,21 +170,19 @@ files:
|
|
133
170
|
- lib/rom/memory/gateway.rb
|
134
171
|
- lib/rom/memory/relation.rb
|
135
172
|
- lib/rom/memory/storage.rb
|
136
|
-
- lib/rom/model_builder.rb
|
137
173
|
- lib/rom/pipeline.rb
|
138
174
|
- lib/rom/plugin.rb
|
175
|
+
- lib/rom/plugin_base.rb
|
139
176
|
- lib/rom/plugin_registry.rb
|
140
177
|
- lib/rom/plugins/relation/registry_reader.rb
|
141
|
-
- lib/rom/processor.rb
|
142
|
-
- lib/rom/processor/transproc.rb
|
143
178
|
- lib/rom/relation.rb
|
144
179
|
- lib/rom/relation/class_interface.rb
|
145
180
|
- lib/rom/relation/composite.rb
|
146
181
|
- lib/rom/relation/curried.rb
|
147
182
|
- lib/rom/relation/graph.rb
|
148
|
-
- lib/rom/relation/lazy.rb
|
149
183
|
- lib/rom/relation/loaded.rb
|
150
184
|
- lib/rom/relation/materializable.rb
|
185
|
+
- lib/rom/relation_registry.rb
|
151
186
|
- lib/rom/repository.rb
|
152
187
|
- lib/rom/setup.rb
|
153
188
|
- lib/rom/setup/finalize.rb
|
@@ -157,15 +192,6 @@ files:
|
|
157
192
|
- lib/rom/setup_dsl/mapper_dsl.rb
|
158
193
|
- lib/rom/setup_dsl/relation.rb
|
159
194
|
- lib/rom/setup_dsl/setup.rb
|
160
|
-
- lib/rom/support/array_dataset.rb
|
161
|
-
- lib/rom/support/class_builder.rb
|
162
|
-
- lib/rom/support/class_macros.rb
|
163
|
-
- lib/rom/support/data_proxy.rb
|
164
|
-
- lib/rom/support/deprecations.rb
|
165
|
-
- lib/rom/support/enumerable_dataset.rb
|
166
|
-
- lib/rom/support/inflector.rb
|
167
|
-
- lib/rom/support/options.rb
|
168
|
-
- lib/rom/support/registry.rb
|
169
195
|
- lib/rom/version.rb
|
170
196
|
- rakelib/benchmark.rake
|
171
197
|
- rakelib/mutant.rake
|
@@ -217,13 +243,10 @@ files:
|
|
217
243
|
- spec/unit/rom/commands/lazy_spec.rb
|
218
244
|
- spec/unit/rom/commands/result_spec.rb
|
219
245
|
- spec/unit/rom/commands_spec.rb
|
220
|
-
- spec/unit/rom/
|
246
|
+
- spec/unit/rom/container_spec.rb
|
221
247
|
- spec/unit/rom/gateway_spec.rb
|
222
248
|
- spec/unit/rom/global_spec.rb
|
223
|
-
- spec/unit/rom/header_spec.rb
|
224
|
-
- spec/unit/rom/mapper/dsl_spec.rb
|
225
249
|
- spec/unit/rom/mapper_registry_spec.rb
|
226
|
-
- spec/unit/rom/mapper_spec.rb
|
227
250
|
- spec/unit/rom/memory/commands/create_spec.rb
|
228
251
|
- spec/unit/rom/memory/commands/delete_spec.rb
|
229
252
|
- spec/unit/rom/memory/commands/update_spec.rb
|
@@ -231,11 +254,10 @@ files:
|
|
231
254
|
- spec/unit/rom/memory/relation_spec.rb
|
232
255
|
- spec/unit/rom/memory/repository_spec.rb
|
233
256
|
- spec/unit/rom/memory/storage_spec.rb
|
234
|
-
- spec/unit/rom/model_builder_spec.rb
|
235
257
|
- spec/unit/rom/plugin_spec.rb
|
236
|
-
- spec/unit/rom/processor/transproc_spec.rb
|
237
258
|
- spec/unit/rom/registry_spec.rb
|
238
259
|
- spec/unit/rom/relation/composite_spec.rb
|
260
|
+
- spec/unit/rom/relation/curried_spec.rb
|
239
261
|
- spec/unit/rom/relation/graph_spec.rb
|
240
262
|
- spec/unit/rom/relation/lazy/combine_spec.rb
|
241
263
|
- spec/unit/rom/relation/lazy_spec.rb
|
@@ -243,11 +265,6 @@ files:
|
|
243
265
|
- spec/unit/rom/relation_spec.rb
|
244
266
|
- spec/unit/rom/repository_spec.rb
|
245
267
|
- spec/unit/rom/setup_spec.rb
|
246
|
-
- spec/unit/rom/support/array_dataset_spec.rb
|
247
|
-
- spec/unit/rom/support/class_builder_spec.rb
|
248
|
-
- spec/unit/rom/support/enumerable_dataset_spec.rb
|
249
|
-
- spec/unit/rom/support/inflector_spec.rb
|
250
|
-
- spec/unit/rom/support/options_spec.rb
|
251
268
|
homepage: http://rom-rb.org
|
252
269
|
licenses:
|
253
270
|
- MIT
|
@@ -263,9 +280,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
280
|
version: '0'
|
264
281
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
282
|
requirements:
|
266
|
-
- - "
|
283
|
+
- - ">"
|
267
284
|
- !ruby/object:Gem::Version
|
268
|
-
version:
|
285
|
+
version: 1.3.1
|
269
286
|
requirements: []
|
270
287
|
rubyforge_project:
|
271
288
|
rubygems_version: 2.4.5
|
data/lib/rom/header.rb
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
require 'equalizer'
|
2
|
-
|
3
|
-
require 'rom/support/options'
|
4
|
-
require 'rom/header/attribute'
|
5
|
-
|
6
|
-
module ROM
|
7
|
-
# Header provides information about data mapping of a specific relation
|
8
|
-
#
|
9
|
-
# Processors use headers to build objects that process raw relations that go
|
10
|
-
# through mappers.
|
11
|
-
#
|
12
|
-
# @private
|
13
|
-
class Header
|
14
|
-
include Enumerable
|
15
|
-
include Options
|
16
|
-
include Equalizer.new(:attributes, :model)
|
17
|
-
|
18
|
-
# @return [Class] optional model associated with a header
|
19
|
-
#
|
20
|
-
# @api private
|
21
|
-
option :model, reader: true
|
22
|
-
|
23
|
-
option :reject_keys, reader: true, default: false
|
24
|
-
|
25
|
-
# @api private
|
26
|
-
attr_reader :attributes
|
27
|
-
|
28
|
-
# @return [Hash] attribute key/name mapping for all primitive attributes
|
29
|
-
#
|
30
|
-
# @api private
|
31
|
-
attr_reader :mapping
|
32
|
-
|
33
|
-
# @return [Array] all attribute keys that are in a tuple
|
34
|
-
#
|
35
|
-
# @api private
|
36
|
-
attr_reader :tuple_keys
|
37
|
-
|
38
|
-
# @return [Array] all attribute names that are popping from a tuple
|
39
|
-
#
|
40
|
-
# @api private
|
41
|
-
attr_reader :pop_keys
|
42
|
-
|
43
|
-
# Coerce array with attribute definitions into a header object
|
44
|
-
#
|
45
|
-
# @param [Array<Array>] input attribute name/option pairs
|
46
|
-
#
|
47
|
-
# @param [Class] model optional
|
48
|
-
#
|
49
|
-
# @return [Header]
|
50
|
-
#
|
51
|
-
# @api private
|
52
|
-
def self.coerce(input, options = {})
|
53
|
-
if input.instance_of?(self)
|
54
|
-
input
|
55
|
-
else
|
56
|
-
attributes = input.each_with_object({}) { |pair, h|
|
57
|
-
h[pair.first] = Attribute.coerce(pair)
|
58
|
-
}
|
59
|
-
|
60
|
-
new(attributes, options)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# @api private
|
65
|
-
def initialize(attributes, options = {})
|
66
|
-
super
|
67
|
-
@attributes = attributes
|
68
|
-
initialize_mapping
|
69
|
-
initialize_tuple_keys
|
70
|
-
initialize_pop_keys
|
71
|
-
end
|
72
|
-
|
73
|
-
# Iterate over attributes
|
74
|
-
#
|
75
|
-
# @yield [Attribute]
|
76
|
-
#
|
77
|
-
# @api private
|
78
|
-
def each
|
79
|
-
attributes.each_value { |attribute| yield(attribute) }
|
80
|
-
end
|
81
|
-
|
82
|
-
# Return if there are any aliased attributes
|
83
|
-
#
|
84
|
-
# @api private
|
85
|
-
def aliased?
|
86
|
-
any?(&:aliased?)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Return attribute keys
|
90
|
-
#
|
91
|
-
# An attribute key corresponds to tuple attribute names
|
92
|
-
#
|
93
|
-
# @api private
|
94
|
-
def keys
|
95
|
-
attributes.keys
|
96
|
-
end
|
97
|
-
|
98
|
-
# Return attribute identified by its name
|
99
|
-
#
|
100
|
-
# @return [Attribute]
|
101
|
-
#
|
102
|
-
# @api private
|
103
|
-
def [](name)
|
104
|
-
attributes.fetch(name)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Return all Combined attributes
|
108
|
-
#
|
109
|
-
# @return [Array<Combined>]
|
110
|
-
#
|
111
|
-
# @api private
|
112
|
-
def combined
|
113
|
-
by_type(Combined)
|
114
|
-
end
|
115
|
-
|
116
|
-
# Returns all attributes that require preprocessing
|
117
|
-
#
|
118
|
-
# @return [Array<Group,Fold>]
|
119
|
-
#
|
120
|
-
# @api private
|
121
|
-
def preprocessed
|
122
|
-
by_type(Group, Fold)
|
123
|
-
end
|
124
|
-
|
125
|
-
# Returns all attributes that require postprocessing
|
126
|
-
#
|
127
|
-
# @return [Array<Ungroup,Unfold>]
|
128
|
-
#
|
129
|
-
# @api private
|
130
|
-
def postprocessed
|
131
|
-
by_type(Ungroup, Unfold)
|
132
|
-
end
|
133
|
-
|
134
|
-
# Return all Wrap attributes
|
135
|
-
#
|
136
|
-
# @return [Array<Wrap>]
|
137
|
-
#
|
138
|
-
# @api private
|
139
|
-
def wraps
|
140
|
-
by_type(Wrap)
|
141
|
-
end
|
142
|
-
|
143
|
-
# Return all non-primitive attributes that don't require mapping
|
144
|
-
#
|
145
|
-
# @return [Array<Group,Fold,Ungroup,Unfold,Wrap,Unwrap>]
|
146
|
-
#
|
147
|
-
# @api private
|
148
|
-
def non_primitives
|
149
|
-
preprocessed + wraps
|
150
|
-
end
|
151
|
-
|
152
|
-
# Return all primitive attributes that require mapping
|
153
|
-
#
|
154
|
-
# @return [Array<Attribute>]
|
155
|
-
#
|
156
|
-
# @api private
|
157
|
-
def primitives
|
158
|
-
to_a - non_primitives
|
159
|
-
end
|
160
|
-
|
161
|
-
private
|
162
|
-
|
163
|
-
# Find all attribute matching specific attribute class (not kind)
|
164
|
-
#
|
165
|
-
# @return [Array<Attribute>]
|
166
|
-
#
|
167
|
-
# @api private
|
168
|
-
def by_type(*types)
|
169
|
-
select { |attribute| types.include?(attribute.class) }
|
170
|
-
end
|
171
|
-
|
172
|
-
# Set mapping hash from primitive attributes
|
173
|
-
#
|
174
|
-
# @api private
|
175
|
-
def initialize_mapping
|
176
|
-
@mapping = primitives.map(&:mapping).reduce(:merge) || {}
|
177
|
-
end
|
178
|
-
|
179
|
-
# Set all tuple keys from all attributes going deep into Wrap and Group too
|
180
|
-
#
|
181
|
-
# @api private
|
182
|
-
def initialize_tuple_keys
|
183
|
-
@tuple_keys = mapping.keys + non_primitives.flat_map(&:tuple_keys)
|
184
|
-
end
|
185
|
-
|
186
|
-
# Set all tuple keys from all attributes popping from Unwrap and Ungroup
|
187
|
-
#
|
188
|
-
# @api private
|
189
|
-
def initialize_pop_keys
|
190
|
-
@pop_keys = mapping.values + non_primitives.flat_map(&:tuple_keys)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|