twirp_rails 0.1.4 → 0.1.5

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: 6a7d8c6c8308b619d98a8719ec069a0896ba0997145646dec8d3be46b92bd3f5
4
- data.tar.gz: f3211a52b907e61e49f546f5f34202b5a4e870b56d23f72fca8a28c877277a2b
3
+ metadata.gz: afb781b860d752d9ccf6eff558d3e07a7f93923ecf5b70dbbb3a7df373ff60c8
4
+ data.tar.gz: ee22bba018427cb6d0c29be51a89bec3a40c464a7a67856b1169d72afecb73b1
5
5
  SHA512:
6
- metadata.gz: b8bc55ff11f35137d883335e92b0d49e50d7bafa75e5a9c7dab9f1632366a71379ff88093709dcccc08b2a2f643c9c2f637448cc6101b898f8c2faa7dd1c22f1
7
- data.tar.gz: e94cff9b2181e4a46343f2a3f0be10fdee43ab88217ca91d01626375f721adffdf39237beab652b8c6c1cd8760abb1f110d68ab6cc92a024437093f2154d2e13
6
+ metadata.gz: d14ef916943fec1782354d2349ae4c38fd918a98331d0f4827c3b7a24847720c01a2d8e414c09b4d39d99ae31bfeffb27fbe5f2d9e13b2444065cf83e0399dab
7
+ data.tar.gz: 7f9ad8ccca240630862a59c107987cf1c3e371392c3e373f5cdb268f04ea24a6db091fe7d5a174bfc58430f1cde21e95e3c74466fd199b647a7bc145c18b9572
data/CHANGELOG.md CHANGED
@@ -4,12 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 0.1.4 - 2020-02-03
7
+ ## 0.1.5 - 2020-02-04
8
8
 
9
9
  ### Added
10
- - convert package.message type to Package::Message
10
+ - rspec ```rpc``` helper try to camelize tested method name if it not exists
11
11
 
12
- ## 0.1.3 - 2020-01-28
12
+ ## 0.1.4 - 2020-02-03
13
13
 
14
14
  ### Added
15
15
  - ```to_twirp``` and ```twirp_message``` methods to easy convert active record models to protobuf DTOs
@@ -29,6 +29,11 @@ describe TeamsHandler do
29
29
  end
30
30
  ```
31
31
 
32
+ ## 0.1.3 - 2020-01-28
33
+
34
+ ### Added
35
+ - convert package.message type to Package::Message
36
+
32
37
  ### Fixed
33
38
  - twirp_ruby missing module workaround https://github.com/twitchtv/twirp-ruby/issues/48
34
39
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twirp_rails (0.1.4)
4
+ twirp_rails (0.1.5)
5
5
  railties (~> 6.0)
6
6
  twirp (~> 1)
7
7
 
@@ -3,7 +3,7 @@ module TwirpRails
3
3
  module Helper
4
4
  extend ActiveSupport::Concern
5
5
 
6
- module ClassMethods
6
+ class_methods do
7
7
  # places to subject service method returned value converted to_h
8
8
  # @param [Boolean] to_h - default true, set to false to use pure result
9
9
  # @param [Proc] block - should return array with method name and arguments
@@ -12,8 +12,21 @@ module TwirpRails
12
12
  # it { should match(id: 1)}
13
13
  def rpc(to_h: true, &block)
14
14
  let :rpc_args, &block
15
+
15
16
  subject do
16
- result = service.call_rpc(*rpc_args)
17
+ method, *args = rpc_args
18
+
19
+ unless service.class.rpcs[method.to_s]
20
+ camelized_method = method.to_s.camelize
21
+
22
+ if service.class.rpcs[camelized_method]
23
+ method = camelized_method
24
+ else
25
+ raise "Methods #{method}/#{camelized_method} is not found in the service #{service.class}"
26
+ end
27
+ end
28
+
29
+ result = service.call_rpc(method, *args)
17
30
  to_h ? result.to_h : result
18
31
  end
19
32
  end
@@ -1,3 +1,3 @@
1
1
  module TwirpRails
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twirp_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Zimin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twirp