fingerprintable 1.1.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 974d5bf19592f7d2d35c604e7f4f5c6b5ad118250a113ca4d6d5c2b3fdc44d8a
4
- data.tar.gz: 780b8605200414ccc134278a06bb413823747432c2552380c20433462f0aafaf
3
+ metadata.gz: 1a826cdad9794857e8bd7b4109f7d952517b978a74484ebea7f51e8bc27e5b37
4
+ data.tar.gz: 0aabbdda60152e10e2ab1b11f7ea681f43631546ec62f880001aee3c5d549160
5
5
  SHA512:
6
- metadata.gz: 98f96e9544657589b1af8a3844d3176d7171ca796dbec1aa0587833b7599b38e7a7d9df69b9df037f1475086eb171c86d14b9029e3754006fc75868aa31bb6c2
7
- data.tar.gz: cc8a16d45ea75a4edec6f1c1789736e625bdb39e3f62e8c9eea36bced14fc9c953dadd815fb6f294a6ec527ab9c917b1df3756d0945fc989e8f5bfdda9edad75
6
+ metadata.gz: 85455073bf0b2c8dcba0de10be70971b483e7505862d832bf1a91a39f6b8affe03d91dbfdd39f881309ecb0ddbd15846a37a0522ba9f0911d79ee945b4b3c7dd
7
+ data.tar.gz: 30410291038b2eb740f0e76de69b981ed4c70ba75771d98bf9295a76aad5022de7a6630cae4cf7bfbd0f78572f4a3a0bd7b12579c1465e7b399f7f2359e7b482
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fingerprintable (1.1.0)
4
+ fingerprintable (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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 = ((object.instance_variables | attributes) - ignore).map(&:to_sym).sort
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.instance_variable_get(attr)]
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
@@ -1,3 +1,3 @@
1
1
  module Fingerprintable
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingerprintable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson