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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0065ff981c378527149acec1b53d95da8b7e610eb8b287ec6790bfc0bb5ea81
4
- data.tar.gz: f8a7d5a735e0b762a2849db99a3a1813a41271c58117ff0e042eed3f2b108464
3
+ metadata.gz: '079162361a0ba7f78020a63e1790a64d3c36e9c0e785f51fdec161945a6881b6'
4
+ data.tar.gz: f83e0ea3fc9498d5ff42b03e44b14d826f0f19c3f645f0e47f95d8814b6fd844
5
5
  SHA512:
6
- metadata.gz: f36e7eac525531cd7394a8660f862a4e736716c261cef300b46f8fc375c869bec9dc48ea0e3762751a2f280fd0ba205317c74c8ebda0284c2714a0b4b41bc5a4
7
- data.tar.gz: 36e0e39cfc2dee3ce019682e8b759bd91cb2ba35fc492205cd7c5b3b9ed6082b64ce9173470540a3ce426103c8f8308dcfb12bc6c7d486c84cf0f7d51b3beca7
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
- [![Circle](https://circleci.com/gh/uvera/trackstamps-reborn/tree/main.svg?style=shield)](https://app.circleci.com/pipelines/github/uvera/trackstamps-reborn?branch=main)
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
 
@@ -1,6 +1,6 @@
1
1
  module Trackstamps
2
2
  module Reborn
3
- class Current < ActiveSupport::CurrentAttributes
3
+ class Current < ::ActiveSupport::CurrentAttributes
4
4
  attribute :user
5
5
  end
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Trackstamps
2
2
  module Reborn
3
- VERSION = "0.0.6".freeze
3
+ VERSION = "0.1.1".freeze
4
4
  end
5
5
  end
@@ -1,7 +1,6 @@
1
- require 'trackstamps/reborn/current'
2
- require 'active_support/current_attributes'
3
- require 'active_support/concern'
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: 'User'.freeze
15
- setting :updater_foreign_key, default: 'updated_by_id'.freeze
16
- setting :creator_foreign_key, default: 'created_by_id'.freeze
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: Trackstamps::Reborn.config.updater_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: Trackstamps::Reborn.config.creator_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("#{Trackstamps::Reborn.config.updater_foreign_key}=", trackstamps_current_user.id)
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("#{Trackstamps::Reborn.config.creator_foreign_key}=", trackstamps_current_user.id)
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.0.6
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: 2022-10-26 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
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.3.23
85
+ rubygems_version: 3.4.1
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: ''