trackstamps-reborn 0.0.6 → 0.1.1
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 +18 -11
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '079162361a0ba7f78020a63e1790a64d3c36e9c0e785f51fdec161945a6881b6'
|
4
|
+
data.tar.gz: f83e0ea3fc9498d5ff42b03e44b14d826f0f19c3f645f0e47f95d8814b6fd844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb01e59feb69a21b6522d46146f45d93492e9e3ff12e42d67a39cf2cb44a570a7b14ce0a8a5fac23cacef4705671637ca4305e30b1dee898dba3c4197e4f8255
|
7
|
+
data.tar.gz: 06ff3787073f509232f6fbeddc51ae36eb8f8a01bcb6bb8fa1b91bd17a025fd9069cda7b6a0f5a5ec31c601649c506037e3bc88ea2afc6a54eabe14e5d0bde86
|
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,33 @@ 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)
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackstamps-reborn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
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: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -34,16 +34,16 @@ dependencies:
|
|
34
34
|
name: dry-configurable
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
39
|
+
version: '1.0'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
46
|
+
version: '1.0'
|
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.
|
85
|
+
rubygems_version: 3.4.1
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: ''
|