rails_surrogate_key_logging 0.3.0 → 0.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d69d68a6bbbb693ad6e0858b770aab8ee4c430e309447bae5b4a7cd222286852
|
4
|
+
data.tar.gz: 9b72303771b0704d71eb69dcd24e1120d7e4de0d755cfb8d07ad2ea520df90e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 128b93f900cf248c250de95e8f4fd64db8ed4c437ffbe1eb40a79fbf002d101e4f3b566622aee962b434a3ebf0b196e559eab45f8a5e6cafc54398a6151a4658
|
7
|
+
data.tar.gz: b15e7ac8901f0d43bf0f95f99e657bb65d90b4a2ec3e9123672ccf8a6464b587b32be03ab523b1b2214ce7cf77d66207a852081821885ba3a60d6099157ee9eb
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SurrogateKeyLogging
|
4
|
+
class ApplicationRecord < ::ActiveRecord::Base
|
5
|
+
self.abstract_class = true
|
6
|
+
|
7
|
+
def self.table_name
|
8
|
+
"#{Rails.application.config.database_configuration["surrogate_key_logging_#{Rails.env}"]['database']}.#{compute_table_name}"
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def table_name_prefix; end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SurrogateKeyLogging
|
4
|
+
class Surrogate < ApplicationRecord
|
5
|
+
class << self
|
6
|
+
def hash_value(value)
|
7
|
+
Digest::SHA512.hexdigest value.to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
def value_for_surrogate(surrogate)
|
11
|
+
where(key: surrogate).select(:value).first&.value
|
12
|
+
end
|
13
|
+
|
14
|
+
def surrogate_for_value(value)
|
15
|
+
where(hashed_value: hash_value(value)).select(:key).first&.key
|
16
|
+
end
|
17
|
+
|
18
|
+
def add(surrogate, value)
|
19
|
+
s = new(key: surrogate, value: value, hashed_value: hash_value(value))
|
20
|
+
s.save
|
21
|
+
end
|
22
|
+
|
23
|
+
def use(surrogate)
|
24
|
+
where(key: surrogate).touch_all
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
'rubygems_mfa_required' => 'true',
|
22
22
|
}
|
23
23
|
|
24
|
-
s.files = Dir['lib/**/*', 'README.md', 'MIT-LICENSE', 'rails_surrogate_key_logging.gemspec']
|
24
|
+
s.files = Dir['app/**/*', 'lib/**/*', 'README.md', 'MIT-LICENSE', 'rails_surrogate_key_logging.gemspec']
|
25
25
|
|
26
26
|
s.require_paths = %w[ lib ]
|
27
27
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_surrogate_key_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Yelverton
|
@@ -97,6 +97,8 @@ extensions: []
|
|
97
97
|
extra_rdoc_files: []
|
98
98
|
files:
|
99
99
|
- README.md
|
100
|
+
- app/models/surrogate_key_logging/application_record.rb
|
101
|
+
- app/models/surrogate_key_logging/surrogate.rb
|
100
102
|
- lib/rails_surrogate_key_logging.rb
|
101
103
|
- lib/surrogate_key_logging.rb
|
102
104
|
- lib/surrogate_key_logging/action_controller.rb
|