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
- if parent_publisher.class_name == subscriber.from_type
8
- parent_publisher
9
- else
10
- parent_publisher.descendants.
11
- select { |pub| pub.class_name == subscriber.from_type }.
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 = subscriber.descendants.map &:from_type
22
- publisher_types = publisher.descendants.map &:class_name
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 "#{publisher} misses some child types: #{missing_types.join(", ")}"
26
+ raise "#{subscriber} does not cover #{missing_types.join(", ")}"
26
27
  end
27
28
  end
28
29
 
29
- unless skip_polymorphic
30
- subscriber.descendants.each do |pub|
31
- self.class.new(options.merge(:subscriber => pub,
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
 
@@ -1,3 +1,3 @@
1
1
  module Promiscuous
2
- VERSION = '0.7.5'
2
+ VERSION = '0.7.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promiscuous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: