obfuscated 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/obfuscated.rb +9 -4
- metadata +3 -3
data/lib/obfuscated.rb
CHANGED
@@ -2,15 +2,14 @@ require 'digest/sha1'
|
|
2
2
|
require 'active_record'
|
3
3
|
|
4
4
|
module Obfuscated
|
5
|
-
|
6
|
-
|
5
|
+
|
7
6
|
def self.append_features(base)
|
8
7
|
super
|
9
8
|
base.extend(ClassMethods)
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.supported?
|
13
|
-
@@mysql_support
|
12
|
+
@@mysql_support ||= ActiveRecord::Base.connection.class.to_s.downcase.include?('mysql') ? true : false
|
14
13
|
end
|
15
14
|
|
16
15
|
module ClassMethods
|
@@ -48,7 +47,9 @@ module Obfuscated
|
|
48
47
|
return id unless Obfuscated::supported?
|
49
48
|
|
50
49
|
# Use SHA1 to generate a consistent hash based on the id and the table name
|
51
|
-
@hashed_id ||= Digest::SHA1.hexdigest(
|
50
|
+
@hashed_id ||= Digest::SHA1.hexdigest(
|
51
|
+
"---#{id}-WICKED-#{self.class.table_name}-"
|
52
|
+
)[0..11]
|
52
53
|
end
|
53
54
|
|
54
55
|
def to_param
|
@@ -58,3 +59,7 @@ module Obfuscated
|
|
58
59
|
end
|
59
60
|
|
60
61
|
end
|
62
|
+
|
63
|
+
ActiveRecord::Base.class_eval do
|
64
|
+
include Obfuscated
|
65
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obfuscated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon Collier
|