serviz 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serviz/version.rb +1 -1
- data/lib/serviz.rb +8 -2
- data/spec/scenarios.rb +11 -0
- data/spec/serviz_spec.rb +7 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a85c4e77120f5d8ad63ede420fc521605ae687ccd6f330e882656dd3f1d0bf
|
4
|
+
data.tar.gz: f9c6b468e1ec02c6ecc342d5673a855bb5c56c3d8f040d8740c4722aa8789eb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99df6f74445b1699e0ad55c5816dfdf858b788456fd241d9141015f755f9afb2227b0388ab5b35a6278c2a1672b21018db7d4605853159fbb50daec9b9876938
|
7
|
+
data.tar.gz: 2a6fcecc5ffc6726d402b053a8a6795d201ac531b2bb69602d1330cb3fde7148072a0095a341ca6e41a98c1c43103ed688148a1a92832ec07808eeed825e1c47
|
data/lib/serviz/version.rb
CHANGED
data/lib/serviz.rb
CHANGED
@@ -4,8 +4,14 @@ module Serviz
|
|
4
4
|
class Base
|
5
5
|
attr_accessor :errors, :result
|
6
6
|
|
7
|
-
def self.call(*args)
|
8
|
-
instance =
|
7
|
+
def self.call(*args, **kwargs)
|
8
|
+
instance = if args.length > 0 && kwargs.length > 0
|
9
|
+
new(*args, **kwargs)
|
10
|
+
elsif kwargs.length > 0
|
11
|
+
new(**kwargs)
|
12
|
+
else
|
13
|
+
new(*args)
|
14
|
+
end
|
9
15
|
instance.call
|
10
16
|
|
11
17
|
instance
|
data/spec/scenarios.rb
CHANGED
@@ -12,5 +12,16 @@ class RegisterUser < Serviz::Base
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
class PositionalAndKeyword < Serviz::Base
|
16
|
+
def initialize(positional, keyword:)
|
17
|
+
@positional = positional
|
18
|
+
@keyword = keyword
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
22
|
+
self.result = [@positional, @keyword]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
class NoCall < Serviz::Base
|
16
27
|
end
|
data/spec/serviz_spec.rb
CHANGED
@@ -21,4 +21,11 @@ RSpec.describe Serviz::Base do
|
|
21
21
|
it "raises exception if #call is not defined" do
|
22
22
|
expect { NoCall.call }.to raise_error NotImplementedError
|
23
23
|
end
|
24
|
+
|
25
|
+
it "accepts positional and keywords args" do
|
26
|
+
operation = PositionalAndKeyword.call('foo', keyword: 'bar')
|
27
|
+
|
28
|
+
expect(operation.success?).to eq true
|
29
|
+
expect(operation.result).to eq(['foo', 'bar'])
|
30
|
+
end
|
24
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markets
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,7 +68,7 @@ homepage: https://github.com/markets/serviz
|
|
68
68
|
licenses:
|
69
69
|
- MIT
|
70
70
|
metadata: {}
|
71
|
-
post_install_message:
|
71
|
+
post_install_message:
|
72
72
|
rdoc_options: []
|
73
73
|
require_paths:
|
74
74
|
- lib
|
@@ -83,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
86
|
+
rubygems_version: 3.4.10
|
87
|
+
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Command object Interface for Ruby
|
90
90
|
test_files:
|