effective_obfuscation 1.3.1 → 1.3.2

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
  SHA1:
3
- metadata.gz: 663ee3b671c5b2e3ff60b0fda8bbba560a0f6b90
4
- data.tar.gz: d359df1a0528541b81a50075bd02000887bd9c25
3
+ metadata.gz: 136beb68fd38439dfe0d5904a5e0e6dd353b939a
4
+ data.tar.gz: a39e154c154df56f985d28bcb8c321491640959d
5
5
  SHA512:
6
- metadata.gz: 817a570976605ae3d0db71c34fc90a0d3f2240616e7f644b5937fcf0f3383438a48db7de41892f5e85b43835bc375eea90328377e70c8e2454db82a5af74c17f
7
- data.tar.gz: f93698009988c21e676dbf09bcbef15400cca631dccf7d6459ffee2e0b482f46f01c825bf5cab2e70728f8502aa491bca62907551e67d2cf85476be93f3194ba
6
+ metadata.gz: 2557b83c462eccf88a25c9bfecaaffadd671c36d19cfec9e9b276aeb5ccf9a2da4452b3a49d876edbe2b005acae6c4f9059aca99e00f5a1d2ec9ee56103ca82c
7
+ data.tar.gz: eb7f98b1704d724814057648ded7c3dc5ee0fff97cdc62329b71001c2371ae6bb03100a4e7229db14d9c9b6635ad3b1a91fa2a8c48a9fc3b43d894e6e5f27ebf
data/README.md CHANGED
@@ -33,7 +33,7 @@ This is a Rails 4 compatible version of obfuscate_id (https://github.com/namick/
33
33
  Add to Gemfile:
34
34
 
35
35
  ```ruby
36
- gem 'effective_obfuscation', :git => 'https://github.com/code-and-effect/effective_obfuscation.git'
36
+ gem 'effective_obfuscation'
37
37
  ```
38
38
 
39
39
  Run the bundle command to install it:
@@ -53,9 +53,7 @@ module ActsAsObfuscated
53
53
  } { |parent| parent.table[:id] }
54
54
  end
55
55
 
56
- if Gem::Version.new(Rails.version) >= Gem::Version.new('4.2') && Gem::Version.new(Rails.version) < Gem::Version.new('5')
57
- extend FinderMethods
58
- end
56
+ extend FinderMethods if EffectiveObfuscation.extend_klass?
59
57
  end
60
58
 
61
59
  module ClassMethods
@@ -113,7 +111,7 @@ module ActsAsObfuscated
113
111
  acts_as_obfuscated_opts[:max_id] ||= (self.unscoped.maximum(:id) rescue 2147483647)
114
112
  end
115
113
 
116
- if Gem::Version.new(Rails.version) < Gem::Version.new('4.2') || Gem::Version.new(Rails.version) >= Gem::Version.new('5')
114
+ if EffectiveObfuscation.extend_relation?
117
115
  def relation
118
116
  super.tap { |relation| relation.extend(FinderMethods) }
119
117
  end
@@ -122,7 +120,9 @@ module ActsAsObfuscated
122
120
 
123
121
  module FinderMethods
124
122
  def find(*args)
125
- return find_by_id(args.first) if (@_effective_obfuscation_reloading || klass.try(:instance_variable_get, :@_effective_obfuscation_reloading))
123
+ if @_effective_obfuscation_reloading || (respond_to?(:klass) && klass.try(:instance_variable_get, :@_effective_obfuscation_reloading))
124
+ return find_by_id(args.first)
125
+ end
126
126
 
127
127
  super(deobfuscate(args.first, false))
128
128
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveObfuscation
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.3.2'.freeze
3
3
  end
@@ -10,4 +10,17 @@ module EffectiveObfuscation
10
10
  def self.show(id, spin)
11
11
  ::ScatterSwap.reverse_hash(id, spin).to_i
12
12
  end
13
+
14
+ def self.extend_klass?
15
+ return false if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
16
+ return true if Gem::Version.new(Rails.version) >= Gem::Version.new('5.1')
17
+ false
18
+ end
19
+
20
+ def self.extend_relation?
21
+ return true if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
22
+ return true if Gem::Version.new(Rails.version) >= Gem::Version.new('5')
23
+ false
24
+ end
25
+
13
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_obfuscation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,9 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.3
41
- description: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the
42
- ID param so curious website visitors are unable to determine your user or order
43
- count.
41
+ description: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the
42
+ ID param so curious website visitors are unable to determine your resource count.
44
43
  email:
45
44
  - info@codeandeffect.com
46
45
  executables: []
@@ -73,9 +72,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
72
  version: '0'
74
73
  requirements: []
75
74
  rubyforge_project:
76
- rubygems_version: 2.4.5.1
75
+ rubygems_version: 2.4.6
77
76
  signing_key:
78
77
  specification_version: 4
79
- summary: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the ID
80
- param so curious website visitors are unable to determine your user or order count.
78
+ summary: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the ID
79
+ param so curious website visitors are unable to determine your resource count.
81
80
  test_files: []