obfuscated 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/obfuscated.rb +6 -5
- metadata +5 -5
data/lib/obfuscated.rb
CHANGED
@@ -6,7 +6,7 @@ module Obfuscated
|
|
6
6
|
|
7
7
|
def self.append_features(base)
|
8
8
|
super
|
9
|
-
base.extend(ClassMethods)
|
9
|
+
base.extend(ClassMethods)
|
10
10
|
base.extend(Finder)
|
11
11
|
end
|
12
12
|
|
@@ -16,10 +16,15 @@ module Obfuscated
|
|
16
16
|
|
17
17
|
module Finder
|
18
18
|
def find( *primary_key )
|
19
|
+
# Sale.find( '7e2d2c4da1b0' )
|
19
20
|
if primary_key.is_a?(String) && primary_key.length == 12
|
20
21
|
find_by_hashed_id( primary_key )
|
22
|
+
|
23
|
+
# Sale.includes(:store).find( '7e2d2c4da1b0' )
|
21
24
|
elsif primary_key.is_a?(Array) && primary_key.length == 1 && primary_key[0].is_a?(String) && primary_key[0].length == 12
|
22
25
|
find_by_hashed_id( primary_key[0] )
|
26
|
+
|
27
|
+
# Other queries
|
23
28
|
else
|
24
29
|
super
|
25
30
|
end
|
@@ -72,7 +77,3 @@ module Obfuscated
|
|
72
77
|
end
|
73
78
|
|
74
79
|
ActiveRecord::Base.class_eval { include Obfuscated }
|
75
|
-
|
76
|
-
# ActiveRelation also needs to get hacked to enable queries like:
|
77
|
-
# Sale.includes(:store).find( '7e2d2c4da1b0' )
|
78
|
-
ActiveRecord::Relation.class_eval { include Obfuscated::Finder }
|
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon Collier
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements: []
|
73
73
|
|
74
74
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.8.
|
75
|
+
rubygems_version: 1.8.24
|
76
76
|
signing_key:
|
77
77
|
specification_version: 3
|
78
78
|
summary: Primary Key Obfuscation
|