trackstamps-reborn 0.0.4 → 0.0.6
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 -9
- data/lib/trackstamps/reborn/version.rb +1 -1
- data/lib/trackstamps/reborn.rb +27 -9
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0065ff981c378527149acec1b53d95da8b7e610eb8b287ec6790bfc0bb5ea81
|
4
|
+
data.tar.gz: f8a7d5a735e0b762a2849db99a3a1813a41271c58117ff0e042eed3f2b108464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f36e7eac525531cd7394a8660f862a4e736716c261cef300b46f8fc375c869bec9dc48ea0e3762751a2f280fd0ba205317c74c8ebda0284c2714a0b4b41bc5a4
|
7
|
+
data.tar.gz: 36e0e39cfc2dee3ce019682e8b759bd91cb2ba35fc492205cd7c5b3b9ed6082b64ce9173470540a3ce426103c8f8308dcfb12bc6c7d486c84cf0f7d51b3beca7
|
data/README.md
CHANGED
@@ -37,15 +37,7 @@ end
|
|
37
37
|
### Override implementation for current user
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
|
41
|
-
|
42
|
-
extend ActiveSupport::Concern
|
43
|
-
include Trackstamps::Reborn
|
44
|
-
|
45
|
-
def trackstamps_current_user
|
46
|
-
User.last
|
47
|
-
end
|
48
|
-
end
|
40
|
+
Trackstamps::Reborn.config.get_current_user = -> { YourCurrentAttributesClass.account }
|
49
41
|
```
|
50
42
|
|
51
43
|
### Generate migrations
|
data/lib/trackstamps/reborn.rb
CHANGED
@@ -1,35 +1,53 @@
|
|
1
1
|
require 'trackstamps/reborn/current'
|
2
2
|
require 'active_support/current_attributes'
|
3
3
|
require 'active_support/concern'
|
4
|
+
require 'dry-configurable'
|
4
5
|
|
5
6
|
module Trackstamps
|
6
7
|
module Reborn
|
8
|
+
extend Dry::Configurable
|
7
9
|
extend ActiveSupport::Concern
|
8
10
|
autoload :VERSION, "trackstamps/reborn/version"
|
9
11
|
|
12
|
+
setting :get_current_user, default: -> { Trackstamps::Reborn::Current.user }
|
13
|
+
|
14
|
+
setting :user_class_name, default: 'User'.freeze
|
15
|
+
setting :updater_foreign_key, default: 'updated_by_id'.freeze
|
16
|
+
setting :creator_foreign_key, default: 'created_by_id'.freeze
|
17
|
+
|
10
18
|
def trackstamps_current_user
|
11
|
-
|
19
|
+
Trackstamps::Reborn.config.get_current_user.call
|
12
20
|
end
|
13
21
|
|
14
|
-
TRACKSTAMPS_USER_CLASS_NAME = 'User'
|
15
|
-
TRACKSTAMPS_UPDATER_FOREIGN_KEY = 'updated_by_id'
|
16
|
-
TRACKSTAMPS_CREATOR_FOREIGN_KEY = 'created_by_id'
|
17
|
-
|
18
22
|
included do
|
19
23
|
before_save :trackstamps_set_updater
|
20
24
|
before_create :trackstamps_set_creator
|
21
25
|
|
22
|
-
belongs_to :updater,
|
23
|
-
|
26
|
+
belongs_to :updater,
|
27
|
+
class_name: Trackstamps::Reborn.config.user_class_name,
|
28
|
+
foreign_key: Trackstamps::Reborn.config.updater_foreign_key,
|
29
|
+
optional: true
|
30
|
+
belongs_to :creator,
|
31
|
+
class_name: Trackstamps::Reborn.config.user_class_name,
|
32
|
+
foreign_key: Trackstamps::Reborn.config.creator_foreign_key,
|
33
|
+
optional: true
|
24
34
|
|
25
35
|
def trackstamps_set_updater
|
26
36
|
return unless trackstamps_current_user
|
27
|
-
|
37
|
+
|
38
|
+
send("#{Trackstamps::Reborn.config.updater_foreign_key}=", trackstamps_current_user.id)
|
28
39
|
end
|
29
40
|
|
30
41
|
def trackstamps_set_creator
|
31
42
|
return unless trackstamps_current_user
|
32
|
-
|
43
|
+
|
44
|
+
send("#{Trackstamps::Reborn.config.creator_foreign_key}=", trackstamps_current_user.id)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class_methods do
|
49
|
+
def with_trackstamps
|
50
|
+
includes(:creator, :updater)
|
33
51
|
end
|
34
52
|
end
|
35
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dušan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '8'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: dry-configurable
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
33
47
|
description:
|
34
48
|
email:
|
35
49
|
- dusan.uveric@mitigate.dev
|
@@ -61,14 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
75
|
requirements:
|
62
76
|
- - ">="
|
63
77
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
78
|
+
version: 2.7.0
|
65
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
81
|
- - ">="
|
68
82
|
- !ruby/object:Gem::Version
|
69
83
|
version: '0'
|
70
84
|
requirements: []
|
71
|
-
rubygems_version: 3.3.
|
85
|
+
rubygems_version: 3.3.23
|
72
86
|
signing_key:
|
73
87
|
specification_version: 4
|
74
88
|
summary: ''
|