ree_lib 1.0.111 → 1.0.113

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59f41ff2397eb9507b0e565246430ccde3467b8137bb747991181cecbb99a8d0
4
- data.tar.gz: c267d40f7cd30a41ab86f428c0f30eec225a96fc6ed3ca33e9ab58cf130c0529
3
+ metadata.gz: cb77d3a2632671effd8c80d733e53f779a7761c085fbccb68dfc52249c7e98ea
4
+ data.tar.gz: 19c54d8117bf8f3dc5e9a6374aa80af299270c3d0e3ff85f3951ead216308f24
5
5
  SHA512:
6
- metadata.gz: 04367c6369bd195fa8f2094159f999a1897485632b3e9c86d7e4ed7909513aeef7ea3beba05d544f7660b5bc9a22522f93cd7e3035da6650fbe60ea580d92045
7
- data.tar.gz: 305010534eb1ed83b5e7a900b2cd88a9429ce6d1c629527af13dd1ecfcc8951b65a3ca68eb3c74c1a65f1d41e6ebce4cff788b4d5525cc787ab3bf13b0ffdebf
6
+ metadata.gz: cc40d56b11b04ba48d5c3e4cea3de8c0fa1292f75bcd1dce90544542fc92ab26cb77a9774831831fc4c38efd0105d2dbff9407814c4ae495a51bff920f310b81
7
+ data.tar.gz: 53a0bf48487d02322766a2a7fac151058dc52678a8d228f20add3161e80c3096e8ec3f5d82b9a6a0d0b88963a90a245b46999e9a62a065260cbda331045d04a6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.111)
4
+ ree_lib (1.0.113)
5
5
  bigdecimal (~> 3.1.6)
6
6
  binding_of_caller (~> 1.0.0)
7
7
  i18n (~> 1.14.1)
@@ -9,6 +9,9 @@
9
9
  "depends_on": [
10
10
  {
11
11
  "name": "ree_object"
12
+ },
13
+ {
14
+ "name": "ree_string"
12
15
  }
13
16
  ],
14
17
  "env_vars": [
@@ -64,7 +64,7 @@ module ReeDto::DtoInstanceMethods
64
64
  def set_value(name, val)
65
65
  if has_value?(name)
66
66
  old = get_value(name)
67
- return if old == val
67
+ return old if old == val
68
68
  end
69
69
 
70
70
  @changed_fields ||= Set.new
@@ -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
- Class.new(DtoCollection) do
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
@@ -3,6 +3,7 @@ module ReeDto
3
3
 
4
4
  package do
5
5
  depends_on :ree_object
6
+ depends_on :ree_string
6
7
  end
7
8
 
8
9
  class << self
@@ -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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.111"
4
+ VERSION = "1.0.113"
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.111
4
+ version: 1.0.113
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov