snapbot 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/snapbot/diagram/renderer.rb +0 -2
- data/lib/snapbot/reflector.rb +14 -0
- data/lib/snapbot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ccc2f9565d40b7b3dd10ffd1f92054e7b718eb28613cdc9336531f35a916204
|
4
|
+
data.tar.gz: 661b49c7b72f6a55736a88fcdafc74e249d6d59c8fcbd115b0fcf6c89442ee51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d19d016d55b593f14106933bb66926d5d9b18b1b986deabfd644ab7f5c27dddb33cfe1ed6ef50952aea72d833eda570937ae6dac1be41d7519c06f403cba64d2
|
7
|
+
data.tar.gz: 22416a76acec3531aa6487de788068c919e69023d9569237daa7990f3db088fe853a3c0a2594632b0edab29a9ea6013921a5379c24878bc6fd8f3d3e89cf04c1
|
data/lib/snapbot/reflector.rb
CHANGED
@@ -44,6 +44,8 @@ module Snapbot
|
|
44
44
|
|
45
45
|
def add_relationships(instance, set)
|
46
46
|
reflect_associations(instance).each do |association|
|
47
|
+
next unless valid_association?(association) # Skip POROs
|
48
|
+
|
47
49
|
records = Array(instance.send(association.name)).compact
|
48
50
|
records.each do |record|
|
49
51
|
set.add(Relationship.new(instance_name(instance), instance_name(record)))
|
@@ -65,6 +67,18 @@ module Snapbot
|
|
65
67
|
|
66
68
|
private
|
67
69
|
|
70
|
+
# rubocop:disable Style/RescueModifier
|
71
|
+
def valid_association?(association)
|
72
|
+
# AR7.x raises an ArgumentError when the class is a PORO. AR6.x would fall over
|
73
|
+
# later with NoMethodError on `relation_delegate_class`. Either way, we're not
|
74
|
+
# valid if the association.klass is not descended from our `base_activerecord_class`
|
75
|
+
return true if (association.klass rescue ArgumentError) < base_activerecord_class
|
76
|
+
|
77
|
+
warn "#{association.active_record} -> :#{association.name} is not a valid association. " \
|
78
|
+
"Make sure it inherits from #{base_activerecord_class}"
|
79
|
+
end
|
80
|
+
# rubocop:enable Style/RescueModifier
|
81
|
+
|
68
82
|
def instance_name(instance)
|
69
83
|
"#{instance.model_name}##{instance.id}"
|
70
84
|
end
|
data/lib/snapbot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Garner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|