hobby-rpc 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hobby/rpc.rb +17 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d9a99da934ca9e20d217853f23e3fdeb8c4d164d55b7f12026baaf18f4806db
4
- data.tar.gz: bd015a31a17d7c906b16b878c9550f33d2f531e17a73d3c1995c7f10192f4705
3
+ metadata.gz: e777a0ddab63f3d1a9973ea235fd8afff5484414578ce3cb6e9432f36973fc61
4
+ data.tar.gz: 96f74c22d807a785aec9665359c3938af231f314c1f12a66b8eaafe1e96cab3b
5
5
  SHA512:
6
- metadata.gz: 30d05b49c19b67c2b1418ebd9974d2e292947c54de17d2118d870d8cb9ad55cb81691ca2e5772f7c198d26ae2c4dc0057f32b1d5e81a4d448e7f86d0d6955e9d
7
- data.tar.gz: 41e57a790ee5f0c75c8539257aef2b6ccee9d6fb04e60b15e5d3001528ac2580da708ce11ec95bdcfabe1f107837c146f1a46afbfa6876735c1c3d90b38f31b0
6
+ metadata.gz: 065fe4de604cbc5030b889a66f715b963edb28b479dda261d2a6ff92a10ef17dbb8057ff048cf101906887bf83dfb53561fca6cd65a4223cab0ac8c3b0e7f341
7
+ data.tar.gz: 32f24e38eca9f459fd266d8c496c32fc60bfe3cb8438727fdbdd2a986cef13f852efb0cdff0d936abdd330f5a2fa0764d198fd1702ec286d383bb7af942a68f3
data/lib/hobby/rpc.rb CHANGED
@@ -5,13 +5,29 @@ module Hobby
5
5
  @roles ||= []
6
6
  end
7
7
 
8
+ # Accepts a `token`(String).
9
+ #
10
+ # This method is for finding a user.
11
+ # It is expected by Hobby::Auth:
12
+ # https://github.com/ch1c0t/hobby-auth
13
+ #
14
+ # If you store all active sessions in one place,
15
+ # you might want to redefine it,
16
+ # since the default implementation below is O(n).
17
+ #
18
+ # Still, it seems to be a reasonable default,
19
+ # because it's ready, by default, for cases when
20
+ # there might be multiple kinds of tokens and multiple ways to store them.
21
+ # And, thanks to Ruby, it's easy to redefine it when it's not needed.
22
+ #
23
+ # Returns a user or nil(if a session for such token does not exist).
8
24
  def self.find_by_token token
9
25
  roles.each do |role|
10
26
  if user = (role.find_by_token token)
11
27
  return user
12
28
  end
13
29
  end
14
- return false
30
+ return nil
15
31
  end
16
32
 
17
33
  def can? _function
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobby-rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-28 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hobby