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.
- checksums.yaml +4 -4
- data/lib/hobby/rpc.rb +17 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e777a0ddab63f3d1a9973ea235fd8afff5484414578ce3cb6e9432f36973fc61
|
4
|
+
data.tar.gz: 96f74c22d807a785aec9665359c3938af231f314c1f12a66b8eaafe1e96cab3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
11
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hobby
|