ree_lib 1.0.106 → 1.0.108

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 558dbd22038f40db477b968aa0595ca664484c05606827276b2d872ad6eb5dab
4
- data.tar.gz: f190528d1cf21d60f1403252fd16d6e9e62beb291b4cddcca2af03f77bddce85
3
+ metadata.gz: 896dcde182ff4343261aa23d3973237260f81e82b9a9a349b7c93f429737fef3
4
+ data.tar.gz: 1cf94f98559f130796b3ac6e66c11071d6cc47fc17f8d6f2ab5792e881c6324b
5
5
  SHA512:
6
- metadata.gz: b5f0cf27786a919265f1c01982c7f8640e5b27edf837ed9a207243e6c513f3a97ab2487ad4c16ebc01feb7d7641509d38b336ef77024fb325b059aa32a61d96e
7
- data.tar.gz: 6ddd53ea7f83cded5374da832c06ef845062c2574e832ccfec241602722a63a32390f78f02fc50f2d030f94b7e1cf404e976c00fa3237c11607cd2fa96504ee7
6
+ metadata.gz: 8827e41de3987b8bf0bbbf8f0178e3612f4ad2303fbce7375510256fcb123ea7432c5cbc5325e8833efe872b8ee9604b2ba8e4237707f539250faca86bb27ab1
7
+ data.tar.gz: 1ab05f373d35931c0750355b4c9fe652e133bc75583a363ebc17973f640d848dc7baba1517d6ed43820136ef0bf0e9957880a0713d72e4e0405f0cc6d433e363
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.106)
4
+ ree_lib (1.0.108)
5
5
  bigdecimal (~> 3.1.6)
6
6
  binding_of_caller (~> 1.0.0)
7
7
  i18n (~> 1.14.1)
@@ -4,7 +4,7 @@ class ReeDto::CollectionMeta
4
4
 
5
5
  attr_reader :name, :contract, :filter_proc
6
6
 
7
- contract Symbol, Any, Proc => Any
7
+ contract Symbol, Any, Nilor[Proc] => Any
8
8
  def initialize(name, contract, filter_proc)
9
9
  @name = name
10
10
  @contract = contract
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.106"
4
+ VERSION = "1.0.108"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.106
4
+ version: 1.0.108
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov