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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0f1bb73ada583b985d01256b290b26feee4bc0d27b941d860ea6b206a402f56
4
- data.tar.gz: 9fd1634babc9613f9be5ad1b07557516ecacce23267a231a5f7306e3749303fb
3
+ metadata.gz: 2a46d28931741a291c5fa524b136533a152e068394c6e80a5f1b01d9ed16d19b
4
+ data.tar.gz: 9216f0f1d7c4a8927fd7909df65c6a175a566b8c58d2e1514f127c41846b479c
5
5
  SHA512:
6
- metadata.gz: bdf9bd8680b72312d25a3d32ea3fc70095709cb09e0ab469d30e918ba63f213910d986110cbe700e5fbcc6a8d3cc8d3129969c900cf17db04889d2fe06fba76a
7
- data.tar.gz: 0b4ad9dc417c68949a5bb1383e8d63752c6705a9f42a298822038195f93ee17b80c83436b1c6fdcc024e1330ba4b54871fea2c84b39a518c91807514ae20ace4
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.1.0"
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"
@@ -88,12 +88,12 @@ class Evil::Client
88
88
 
89
89
  # Model instance constructor
90
90
  #
91
- # @param [Hash] op Model options
91
+ # @param [Hash] options The list of options as a plain hash
92
92
  # @return [Evil::Client::Model]
93
93
  #
94
- def new(**op)
95
- op = Hash(op).transform_keys(&:to_sym)
96
- super(**op).tap { |item| in_english { policy[item].validate! } }
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
@@ -108,18 +108,40 @@ RSpec.describe Evil::Client::Model do
108
108
 
109
109
  subject { model }
110
110
 
111
- it "behaves like a model" do
112
- expect(subject).to be_a klass
113
- expect(subject.email).to eq "joe@example.com"
114
- end
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
- it "injects options from the other model" do
117
- expect(subject.first_name).to eq "Joe"
118
- expect(subject.last_name).to eq "Doe"
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
- it "injects memoizers from the other model" do
122
- expect(subject.name).to eq "Joe Doe"
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.1.0
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: 2022-07-04 00:00:00.000000000 Z
12
+ date: 2023-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-initializer