Skip to content

Commit

Permalink
Refactoring logic around evaluating entity
Browse files Browse the repository at this point in the history
For some reason this was breaking specs once rebased (no shame, it
happens!) Reworking the logic a bit, I did spot one possible bug so
changed the code slightly by adding a SNO (&) and forced a return value
from the extracted method. Specs are now running clean.
  • Loading branch information
kerrizor committed May 12, 2019
1 parent 895eb06 commit dee8d32
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rails_erd/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ def check_association_validity(association)
def check_polymorphic_association_validity(association)
entity_name = association.class_name
entity = entity_by_name(entity_name)
if entity.nil? || entity.generalized?
raise "polymorphic interface #{entity_name} does not exist"

if entity || entity&.generalized?
return entity
else
raise("polymorphic interface #{entity_name} does not exist")
end
end

Expand Down

0 comments on commit dee8d32

Please sign in to comment.