ree_lib 1.0.112 → 1.0.113
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.schema.json +3 -0
- data/lib/ree_lib/packages/ree_dto/package/ree_dto/functions/build_dto.rb +1 -1
- data/lib/ree_lib/packages/ree_dto/package/ree_dto/functions/build_dto_collection_class.rb +10 -3
- data/lib/ree_lib/packages/ree_dto/package/ree_dto.rb +1 -0
- data/lib/ree_lib/packages/ree_dto/spec/ree_dto/dsl_spec.rb +4 -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: cb77d3a2632671effd8c80d733e53f779a7761c085fbccb68dfc52249c7e98ea
|
4
|
+
data.tar.gz: 19c54d8117bf8f3dc5e9a6374aa80af299270c3d0e3ff85f3951ead216308f24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc40d56b11b04ba48d5c3e4cea3de8c0fa1292f75bcd1dce90544542fc92ab26cb77a9774831831fc4c38efd0105d2dbff9407814c4ae495a51bff920f310b81
|
7
|
+
data.tar.gz: 53a0bf48487d02322766a2a7fac151058dc52678a8d228f20add3161e80c3096e8ec3f5d82b9a6a0d0b88963a90a245b46999e9a62a065260cbda331045d04a6
|
data/Gemfile.lock
CHANGED
@@ -46,7 +46,7 @@ class ReeDto::BuildDto
|
|
46
46
|
end
|
47
47
|
|
48
48
|
builder.collections.each do |collection|
|
49
|
-
col_class = build_dto_collection_class(collection.contract)
|
49
|
+
col_class = build_dto_collection_class(klass, collection.name, collection.contract)
|
50
50
|
col_class.class_exec(&collection.filter_proc) if collection.filter_proc
|
51
51
|
|
52
52
|
klass.instance_exec do
|
@@ -2,12 +2,15 @@ class ReeDto::BuildDtoCollectionClass
|
|
2
2
|
include Ree::FnDSL
|
3
3
|
|
4
4
|
fn :build_dto_collection_class do
|
5
|
+
link :camelize, from: :ree_string
|
5
6
|
link "ree_dto/dto/dto_collection", -> { DtoCollection }
|
6
7
|
end
|
7
8
|
|
8
|
-
contract Any => Class
|
9
|
-
def call(entity_contract)
|
10
|
-
|
9
|
+
contract Class, Symbol, Any => Class
|
10
|
+
def call(klass, collection_name, entity_contract)
|
11
|
+
name = camelize(collection_name.to_s)
|
12
|
+
|
13
|
+
const = Class.new(DtoCollection) do
|
11
14
|
contract entity_contract => nil
|
12
15
|
def add(item)
|
13
16
|
@list ||= []
|
@@ -23,5 +26,9 @@ class ReeDto::BuildDtoCollectionClass
|
|
23
26
|
alias :<< :add
|
24
27
|
alias :push :add
|
25
28
|
end
|
29
|
+
|
30
|
+
const_name = "#{name}CollectionDto"
|
31
|
+
klass.const_set(const_name, const)
|
32
|
+
klass.const_get(const_name)
|
26
33
|
end
|
27
34
|
end
|
@@ -90,6 +90,10 @@ RSpec.describe ReeDto::DSL do
|
|
90
90
|
|
91
91
|
dto.numbers << 1
|
92
92
|
dto.numbers << 2
|
93
|
+
|
94
|
+
expect(dto.numbers.class).to eq(ReeDto::DtoClass::NumbersCollectionDto)
|
95
|
+
expect(dto.users.class).to eq(ReeDto::DtoClass::UsersCollectionDto)
|
96
|
+
expect(dto.active_users.class).to eq(ReeDto::DtoClass::ActiveUsersCollectionDto)
|
93
97
|
expect(dto.numbers.sum).to eq(3)
|
94
98
|
expect(dto.numbers.to_s).to eq("odd_collection")
|
95
99
|
}
|
data/lib/ree_lib/version.rb
CHANGED