ree_lib 1.0.106 → 1.0.108
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ree_lib/packages/ree_dto/package/ree_dto/dto/collection_meta.rb +1 -1
- data/lib/ree_lib/packages/ree_dto/package/ree_dto/functions/build_dto.rb +20 -1
- data/lib/ree_lib/packages/ree_dto/spec/ree_dto/dsl_spec.rb +9 -0
- data/lib/ree_lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 896dcde182ff4343261aa23d3973237260f81e82b9a9a349b7c93f429737fef3
|
4
|
+
data.tar.gz: 1cf94f98559f130796b3ac6e66c11071d6cc47fc17f8d6f2ab5792e881c6324b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8827e41de3987b8bf0bbbf8f0178e3612f4ad2303fbce7375510256fcb123ea7432c5cbc5325e8833efe872b8ee9604b2ba8e4237707f539250faca86bb27ab1
|
7
|
+
data.tar.gz: 1ab05f373d35931c0750355b4c9fe652e133bc75583a363ebc17973f640d848dc7baba1517d6ed43820136ef0bf0e9957880a0713d72e4e0405f0cc6d433e363
|
data/Gemfile.lock
CHANGED
@@ -10,6 +10,7 @@ class ReeDto::BuildDto
|
|
10
10
|
link "ree_dto/dto/dto_instance_methods", -> { DtoInstanceMethods }
|
11
11
|
link "ree_dto/dto/dto_class_methods", -> { DtoClassMethods }
|
12
12
|
link "ree_dto/dto/dto_builder", -> { DtoBuilder }
|
13
|
+
link "ree_dto/dto/dto_collection", -> { DtoCollection }
|
13
14
|
end
|
14
15
|
|
15
16
|
contract(Block => nil)
|
@@ -46,7 +47,25 @@ class ReeDto::BuildDto
|
|
46
47
|
|
47
48
|
builder.collections.each do |collection|
|
48
49
|
col_class = build_dto_collection_class(collection.contract)
|
49
|
-
col_class.class_exec(&collection.filter_proc)
|
50
|
+
col_class.class_exec(&collection.filter_proc) if collection.filter_proc
|
51
|
+
|
52
|
+
klass.instance_exec do
|
53
|
+
contract ArrayOf[collection.contract] => DtoCollection
|
54
|
+
end
|
55
|
+
|
56
|
+
klass.define_method "#{collection.name}=" do |list|
|
57
|
+
col = send(collection.name)
|
58
|
+
|
59
|
+
list.each do |item|
|
60
|
+
col.add(item)
|
61
|
+
end
|
62
|
+
|
63
|
+
col
|
64
|
+
end
|
65
|
+
|
66
|
+
klass.instance_exec do
|
67
|
+
contract None => DtoCollection
|
68
|
+
end
|
50
69
|
|
51
70
|
klass.define_method collection.name do
|
52
71
|
@collections ||= {}
|
@@ -20,6 +20,8 @@ RSpec.describe ReeDto::DSL do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
collection :active_users, User
|
24
|
+
|
23
25
|
collection :users, User do
|
24
26
|
filter :active, -> { _1.status == "active" }
|
25
27
|
filter :inactive, -> { _1.status != "active" }
|
@@ -92,6 +94,13 @@ RSpec.describe ReeDto::DSL do
|
|
92
94
|
expect(dto.numbers.to_s).to eq("odd_collection")
|
93
95
|
}
|
94
96
|
|
97
|
+
it {
|
98
|
+
dto = ReeDto::DtoClass.new
|
99
|
+
|
100
|
+
dto.numbers = [1, 2, 3, 4]
|
101
|
+
expect(dto.numbers.to_a).to eq([1, 2, 3, 4])
|
102
|
+
}
|
103
|
+
|
95
104
|
it {
|
96
105
|
dto = ReeDto::DtoClass.new
|
97
106
|
|
data/lib/ree_lib/version.rb
CHANGED