evil-client 3.1.0 → 3.2.0
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 +4 -4
- data/CHANGELOG.md +7 -1
- data/evil-client.gemspec +1 -1
- data/lib/evil/client/model.rb +4 -4
- data/spec/unit/model_spec.rb +31 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a46d28931741a291c5fa524b136533a152e068394c6e80a5f1b01d9ed16d19b
|
4
|
+
data.tar.gz: 9216f0f1d7c4a8927fd7909df65c6a175a566b8c58d2e1514f127c41846b479c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 259a4f0a8202467ee57e6258b02b8f9cc15c425fa765a9e346f1163f8abcfc764fe6b33ab59bfb35cb69a8ac99baa2dbfbc5c19fabc1aede16e19353632dd38a
|
7
|
+
data.tar.gz: a4b2ead1c4658687cede34df8b7865c0ee3df34a5367272a046c98347b54f3a5713d8d42182c801b5134705cb3b6676e1bdc307f31b3129c79b6ecaf9d07c07d
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog], and this project adheres
|
5
5
|
to [Semantic Versioning].
|
6
6
|
|
7
|
+
## [3.2.0] [2023-01-18]
|
8
|
+
|
9
|
+
### Added
|
10
|
+
- Support for plain hash argument in the model (@nepalez)
|
11
|
+
|
7
12
|
## [3.1.0] [2022-07-04]
|
8
13
|
|
9
14
|
### Added
|
@@ -501,4 +506,5 @@ formats will be added.
|
|
501
506
|
[3.0.3]: https://github.com/evilmartians/evil-client/compare/v3.0.2...v3.0.3
|
502
507
|
[3.0.4]: https://github.com/evilmartians/evil-client/compare/v3.0.3...v3.0.4
|
503
508
|
[3.0.5]: https://github.com/evilmartians/evil-client/compare/v3.0.4...v3.0.5
|
504
|
-
[3.1.0]: https://github.com/evilmartians/evil-client/compare/v3.0.5...v3.1.0
|
509
|
+
[3.1.0]: https://github.com/evilmartians/evil-client/compare/v3.0.5...v3.1.0
|
510
|
+
[3.1.0]: https://github.com/evilmartians/evil-client/compare/v3.1.0...v3.2.0
|
data/evil-client.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "evil-client"
|
3
|
-
gem.version = "3.
|
3
|
+
gem.version = "3.2.0"
|
4
4
|
gem.author = ["Andrew Kozin (nepalez)", "Ravil Bairamgalin (brainopia)"]
|
5
5
|
gem.email = ["andrew.kozin@gmail.com", "nepalez@evilmartians.com"]
|
6
6
|
gem.homepage = "https://github.com/evilmartians/evil-client"
|
data/lib/evil/client/model.rb
CHANGED
@@ -88,12 +88,12 @@ class Evil::Client
|
|
88
88
|
|
89
89
|
# Model instance constructor
|
90
90
|
#
|
91
|
-
# @param
|
91
|
+
# @param [Hash] options The list of options as a plain hash
|
92
92
|
# @return [Evil::Client::Model]
|
93
93
|
#
|
94
|
-
def new(**
|
95
|
-
|
96
|
-
super(**
|
94
|
+
def new(options = {}, **kwargs)
|
95
|
+
kwargs = Hash(options).transform_keys(&:to_sym).merge(kwargs)
|
96
|
+
super(**kwargs).tap { |item| in_english { policy[item].validate! } }
|
97
97
|
end
|
98
98
|
alias call new
|
99
99
|
alias [] call
|
data/spec/unit/model_spec.rb
CHANGED
@@ -108,18 +108,40 @@ RSpec.describe Evil::Client::Model do
|
|
108
108
|
|
109
109
|
subject { model }
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
context "with kwargs" do
|
112
|
+
let(:model) { klass.new(**options) }
|
113
|
+
|
114
|
+
it "behaves like a model" do
|
115
|
+
expect(subject).to be_a klass
|
116
|
+
expect(subject.email).to eq "joe@example.com"
|
117
|
+
end
|
115
118
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
it "injects options from the other model" do
|
120
|
+
expect(subject.first_name).to eq "Joe"
|
121
|
+
expect(subject.last_name).to eq "Doe"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "injects memoizers from the other model" do
|
125
|
+
expect(subject.name).to eq "Joe Doe"
|
126
|
+
end
|
119
127
|
end
|
120
128
|
|
121
|
-
|
122
|
-
|
129
|
+
context "with hash argument" do
|
130
|
+
let(:model) { klass.new(options) }
|
131
|
+
|
132
|
+
it "behaves like a model" do
|
133
|
+
expect(subject).to be_a klass
|
134
|
+
expect(subject.email).to eq "joe@example.com"
|
135
|
+
end
|
136
|
+
|
137
|
+
it "injects options from the other model" do
|
138
|
+
expect(subject.first_name).to eq "Joe"
|
139
|
+
expect(subject.last_name).to eq "Doe"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "injects memoizers from the other model" do
|
143
|
+
expect(subject.name).to eq "Joe Doe"
|
144
|
+
end
|
123
145
|
end
|
124
146
|
|
125
147
|
context "with invalid options" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin (nepalez)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-initializer
|