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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 805e14e9b7c71c440d12245bffb67e6494ca4597ac93ffb3a96175ac95ea1db1
4
- data.tar.gz: 4c907bd4276695b00e03265068d3576f2334a49153d25b31574f3fe63159e69a
3
+ metadata.gz: cb77d3a2632671effd8c80d733e53f779a7761c085fbccb68dfc52249c7e98ea
4
+ data.tar.gz: 19c54d8117bf8f3dc5e9a6374aa80af299270c3d0e3ff85f3951ead216308f24
5
5
  SHA512:
6
- metadata.gz: 8f5fcce535a876c3d4ae1cd088ffcc145d5e370c3e51697f264bc3bfe7256b48d2b3823bf4a3a9f5849cbcf404a67007a8b6154f6736cca48063a70ff3414c06
7
- data.tar.gz: 7dc29a59ff0816c0008feedbbabd9ac20749bd6eac95320da92b22b4f326f8cb3b9e3617f91d5296d8fcd19642377eacb3521a8e236ca2a8b72b486a5bcf5db5
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.112)
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": [
@@ -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.112"
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.112
4
+ version: 1.0.113
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov