promiscuous 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -3,35 +3,33 @@ module Promiscuous::Subscriber::Lint::Polymorphic
|
|
3
3
|
|
4
4
|
def publisher
|
5
5
|
parent_publisher = super
|
6
|
-
if parent_publisher
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
first
|
13
|
-
end
|
14
|
-
end
|
6
|
+
return nil if parent_publisher.nil?
|
7
|
+
|
8
|
+
publishers.
|
9
|
+
select { |pub| pub <= parent_publisher }.
|
10
|
+
select { |pub| pub.class_name == subscriber.from_type }.
|
11
|
+
first
|
15
12
|
end
|
16
13
|
|
17
14
|
def lint
|
18
15
|
super
|
16
|
+
return if skip_polymorphic
|
17
|
+
|
18
|
+
sub_descendants = subscriber.descendants
|
19
|
+
pub_descendants = publishers.select { |pub| pub < publisher }
|
19
20
|
|
20
21
|
if check_publisher
|
21
|
-
subscriber_types =
|
22
|
-
publisher_types =
|
22
|
+
subscriber_types = sub_descendants.map &:from_type
|
23
|
+
publisher_types = pub_descendants.map &:class_name
|
23
24
|
missing_types = publisher_types - subscriber_types
|
24
25
|
if missing_types.present?
|
25
|
-
raise "#{
|
26
|
+
raise "#{subscriber} does not cover #{missing_types.join(", ")}"
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
:klass => nil,
|
33
|
-
:skip_polymorphic => true)).lint
|
34
|
-
end
|
30
|
+
sub_descendants.each do |pub|
|
31
|
+
self.class.new(options.merge(:klass => nil, :subscriber => pub,
|
32
|
+
:skip_polymorphic => true)).lint
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
data/lib/promiscuous/version.rb
CHANGED