current_session 0.1.3 → 0.1.4

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: b1b39dda8338daaeb45ccebe39f01c23931d9387685619750a65c0a1acc7f6cb
4
- data.tar.gz: 8214ca0c3d15c9d8cb27a963ba41e5e7cd71375c1e2d24ea616972b3beeed193
3
+ metadata.gz: bc53442f7b800e43a4da8cc2690d72ba5466be6afce2b6d28fed7e3e62de9fea
4
+ data.tar.gz: 46364f6ee395e2e2734cb0784cf700793dafb022963960d7478a5397feac8bd0
5
5
  SHA512:
6
- metadata.gz: 0e1e74c3e85d3806e3d8235f396f67d5132a7ff3ba49bd384d3a0bb316073ec9d17bf3f546a92754c0beceb43b08740532ec75a4a25a32c8cc9f835fcec29f7f
7
- data.tar.gz: 3c0f7bba4344ab4be82509930173accd0b76712ee07b3dbb8018f788a22304d467c27478aa9ca7691ebecb794f7783cf835cecf8b9ed90f6bcdb005cc8e2df2e
6
+ metadata.gz: 95c0d5af5fd5a896d277ccbb5955675ddaa04ee2caf52b41918c1aa1eae6cf0ca15d3c0cf781eddba225b3eef613a377054309347ddb3f1ae3e45b1f2002562f
7
+ data.tar.gz: f8e4b72b8bab60b40af08cf0a7fedcb8cc9613e7aab7a73a8d5d97b4fb7732ccccbd59c8a76890daed5b6382efe9f6e6c9a894fc99db18a9c7a316b99d9ed7b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- current_session (0.1.3)
4
+ current_session (0.1.4)
5
5
  activesupport (>= 6.0.0)
6
6
 
7
7
  GEM
@@ -5,11 +5,12 @@ module CurrentSession
5
5
  # Base class for providing auth methods
6
6
  #
7
7
  class Auth
8
- def initialize(request, user_class)
8
+ class_attribute :user_class
9
+
10
+ def initialize(request)
9
11
  @request = request
10
- @user_class = user_class
11
12
  end
12
- attr_reader :request, :user_class
13
+ attr_reader :request
13
14
 
14
15
  def auth
15
16
  request.env["omniauth.auth"]
@@ -10,7 +10,13 @@ module CurrentSession
10
10
  attribute :current_user
11
11
 
12
12
  class << self
13
- attr_accessor :user_class, :session_token_class
13
+ attr_accessor :session_token_class
14
+ attr_reader :user_class
15
+
16
+ def user_class=(user_class)
17
+ @user_class = user_class
18
+ @auth_class.user_class = user_class if @auth_class
19
+ end
14
20
 
15
21
  def current_time(_)
16
22
  Time.current
@@ -24,8 +30,9 @@ module CurrentSession
24
30
  if block
25
31
  session_methods = Module.new(&block)
26
32
  @session_repository_class = Class.new(CurrentSession::Repository) { include session_methods }
33
+ @session_methods = session_methods
27
34
  else
28
- @session_repository_class
35
+ @session_methods
29
36
  end
30
37
  end
31
38
 
@@ -37,8 +44,10 @@ module CurrentSession
37
44
  if block
38
45
  auth_methods = Module.new(&block)
39
46
  @auth_class = Class.new(CurrentSession::Auth) { include auth_methods }
47
+ @auth_class.user_class = user_class
48
+ @auth_methods = auth_methods
40
49
  else
41
- @auth_class
50
+ @auth_methods
42
51
  end
43
52
  end
44
53
  end
@@ -19,7 +19,7 @@ module CurrentSession
19
19
  end
20
20
 
21
21
  def create(request)
22
- auth = @auth_class.new(request, user_class)
22
+ auth = @auth_class.new(request)
23
23
  auth.find_or_create_by_auth.try do |user|
24
24
  auth.update(user)
25
25
  session_repository(request).update_session_token(user)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CurrentSession
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: current_session
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masa (Aileron inc)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-30 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport