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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 177871346c263a1cd84842ef37ffa32e1fd4a398242e4d050821b2c12e5b705c
4
- data.tar.gz: 1e65d0ea46eae2a2e0914445a55b73fa32e5f256affdd4549a11d047c4cb4181
3
+ metadata.gz: c6a85c4e77120f5d8ad63ede420fc521605ae687ccd6f330e882656dd3f1d0bf
4
+ data.tar.gz: f9c6b468e1ec02c6ecc342d5673a855bb5c56c3d8f040d8740c4722aa8789eb5
5
5
  SHA512:
6
- metadata.gz: 6ab5a8ab13a585d3d76d434b97a8ef16d2280756ecae1eadbb38c20f2a408599f0ceebe60c98a42430d1ee55889affee566ee7ab4ada8a533008a8791e0275a0
7
- data.tar.gz: 84b5f495b341bf886e68340dcac0b0ce1ff4afce744c7a6fa89e10e7c4b07bbbc7b454c79a802b794730f1c5af5fe9f50086ce74755bc7a25e6e6202e4ab22ca
6
+ metadata.gz: 99df6f74445b1699e0ad55c5816dfdf858b788456fd241d9141015f755f9afb2227b0388ab5b35a6278c2a1672b21018db7d4605853159fbb50daec9b9876938
7
+ data.tar.gz: 2a6fcecc5ffc6726d402b053a8a6795d201ac531b2bb69602d1330cb3fde7148072a0095a341ca6e41a98c1c43103ed688148a1a92832ec07808eeed825e1c47
@@ -1,3 +1,3 @@
1
1
  module Serviz
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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 = new(*args)
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.2.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: 2020-07-02 00:00:00.000000000 Z
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.0.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: