fingerprintable 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fingerprintable/fingerprinter.rb +12 -3
- data/lib/fingerprintable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a826cdad9794857e8bd7b4109f7d952517b978a74484ebea7f51e8bc27e5b37
|
4
|
+
data.tar.gz: 0aabbdda60152e10e2ab1b11f7ea681f43631546ec62f880001aee3c5d549160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85455073bf0b2c8dcba0de10be70971b483e7505862d832bf1a91a39f6b8affe03d91dbfdd39f881309ecb0ddbd15846a37a0522ba9f0911d79ee945b4b3c7dd
|
7
|
+
data.tar.gz: 30410291038b2eb740f0e76de69b981ed4c70ba75771d98bf9295a76aad5022de7a6630cae4cf7bfbd0f78572f4a3a0bd7b12579c1465e7b399f7f2359e7b482
|
data/Gemfile.lock
CHANGED
@@ -17,7 +17,7 @@ module Fingerprintable
|
|
17
17
|
@fallback_to_string = fallback_to_string
|
18
18
|
@ignore = ignore | ignore.map { |e| "@#{e}".to_sym }
|
19
19
|
@object = object
|
20
|
-
@attributes = (
|
20
|
+
@attributes = populate_attributes(attributes: attributes, ignore: ignore)
|
21
21
|
@cache = cache || {}
|
22
22
|
@cache[object] = next_cache_id
|
23
23
|
@fingerprinted = false
|
@@ -69,7 +69,7 @@ module Fingerprintable
|
|
69
69
|
|
70
70
|
def object_values_hash
|
71
71
|
@object_values_hash ||= Hash[attributes.map do |attr|
|
72
|
-
[attr, object.
|
72
|
+
[attr, object.send(attr)]
|
73
73
|
end]
|
74
74
|
end
|
75
75
|
|
@@ -117,8 +117,17 @@ module Fingerprintable
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def next_cache_id
|
120
|
-
# "#{SecureRandom.uuid}-#{@cache.count}"
|
121
120
|
@cache.count
|
122
121
|
end
|
122
|
+
|
123
|
+
def populate_attributes(attributes:, ignore:)
|
124
|
+
instance_variables = Hash[object.instance_variables.map { |e| [e, 1] }]
|
125
|
+
ret = object.class.instance_methods.select do |method|
|
126
|
+
instance_variables.key?("@#{method}".to_sym)
|
127
|
+
end
|
128
|
+
ret |= attributes
|
129
|
+
ret -= ignore
|
130
|
+
ret.map(&:to_sym).sort
|
131
|
+
end
|
123
132
|
end
|
124
133
|
end
|