trackstamps-reborn 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/trackstamps/reborn/current.rb +1 -1
- data/lib/trackstamps/reborn/version.rb +1 -1
- data/lib/trackstamps/reborn.rb +24 -11
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2913a46aba0967d1226ed02f93e86d219c93b97ae295e1754c208dbefb90b1d
|
4
|
+
data.tar.gz: 2af412096b4d54fa9ea08557c0d560d508763b11a468216bd5beb25b65c53ef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fbbe08e654b28afcc671f76ed61f4d52f16fc0a757770027e7e9939d489f73a5fb4810baf38b74f10f4033ff6ea0c008ac594f1ba0980b5f849966389882413
|
7
|
+
data.tar.gz: 2f029a844e3ad1a92efd6c97e4c49dd6d2c94d9e990fffe7638c7a07ed239c2aaec32311e6840e387184fcdd27c6225c489bea3ea00527640d7ebab20abb5179
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# trackstamps-reborn
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/trackstamps-reborn.svg)](https://rubygems.org/gems/trackstamps-reborn)
|
4
|
-
[![
|
5
|
-
[![Code Climate](https://codeclimate.com/github/uvera/trackstamps-reborn/badges/gpa.svg)](https://codeclimate.com/github/uvera/trackstamps-reborn)
|
4
|
+
[![Test](https://github.com/uvera/trackstamps-reborn/actions/workflows/test.yml/badge.svg)](https://github.com/uvera/trackstamps-reborn/actions/workflows/test.yml)
|
6
5
|
|
7
6
|
Track which user created or updated record in Rails.
|
8
7
|
|
data/lib/trackstamps/reborn.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'dry-configurable'
|
1
|
+
require "active_support"
|
2
|
+
require "trackstamps/reborn/current"
|
3
|
+
require "dry-configurable"
|
5
4
|
|
6
5
|
module Trackstamps
|
7
6
|
module Reborn
|
@@ -11,9 +10,9 @@ module Trackstamps
|
|
11
10
|
|
12
11
|
setting :get_current_user, default: -> { Trackstamps::Reborn::Current.user }
|
13
12
|
|
14
|
-
setting :user_class_name, default:
|
15
|
-
setting :updater_foreign_key, default:
|
16
|
-
setting :creator_foreign_key, default:
|
13
|
+
setting :user_class_name, default: "User".freeze
|
14
|
+
setting :updater_foreign_key, default: "updated_by_id".freeze
|
15
|
+
setting :creator_foreign_key, default: "created_by_id".freeze
|
17
16
|
|
18
17
|
def trackstamps_current_user
|
19
18
|
Trackstamps::Reborn.config.get_current_user.call
|
@@ -23,25 +22,39 @@ module Trackstamps
|
|
23
22
|
before_save :trackstamps_set_updater
|
24
23
|
before_create :trackstamps_set_creator
|
25
24
|
|
25
|
+
const_set(:UPDATER_FOREIGN_KEY, Trackstamps::Reborn.config.updater_foreign_key.dup.freeze)
|
26
|
+
|
27
|
+
private_constant :UPDATER_FOREIGN_KEY
|
28
|
+
|
26
29
|
belongs_to :updater,
|
27
30
|
class_name: Trackstamps::Reborn.config.user_class_name,
|
28
|
-
foreign_key:
|
31
|
+
foreign_key: const_get(:UPDATER_FOREIGN_KEY),
|
29
32
|
optional: true
|
33
|
+
|
34
|
+
const_set(:CREATOR_FOREIGN_KEY, Trackstamps::Reborn.config.creator_foreign_key.dup.freeze)
|
35
|
+
private_constant :CREATOR_FOREIGN_KEY
|
36
|
+
|
30
37
|
belongs_to :creator,
|
31
38
|
class_name: Trackstamps::Reborn.config.user_class_name,
|
32
|
-
foreign_key:
|
39
|
+
foreign_key: const_get(:CREATOR_FOREIGN_KEY),
|
33
40
|
optional: true
|
34
41
|
|
35
42
|
def trackstamps_set_updater
|
36
43
|
return unless trackstamps_current_user
|
37
44
|
|
38
|
-
send("#{
|
45
|
+
send("#{self.class.const_get(:UPDATER_FOREIGN_KEY)}=", trackstamps_current_user.id)
|
39
46
|
end
|
40
47
|
|
41
48
|
def trackstamps_set_creator
|
42
49
|
return unless trackstamps_current_user
|
43
50
|
|
44
|
-
send("#{
|
51
|
+
send("#{self.class.const_get(:CREATOR_FOREIGN_KEY)}=", trackstamps_current_user.id)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class_methods do
|
56
|
+
def with_trackstamps
|
57
|
+
includes(:creator, :updater)
|
45
58
|
end
|
46
59
|
end
|
47
60
|
end
|
metadata
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackstamps-reborn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dušan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dry-configurable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5.2'
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '1.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '5.2'
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '1.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: rails
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
33
|
+
version: '5.2'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '8'
|
40
37
|
type: :runtime
|
41
38
|
prerelease: false
|
42
39
|
version_requirements: !ruby/object:Gem::Requirement
|
43
40
|
requirements:
|
44
41
|
- - ">="
|
45
42
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
43
|
+
version: '5.2'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '8'
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- dusan.uveric@mitigate.dev
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.3.
|
85
|
+
rubygems_version: 3.3.25
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: ''
|