Skip to content

Commit

Permalink
Merge pull request #103 from kerrizor/avoid-null-objects-in-sort
Browse files Browse the repository at this point in the history
Use NullObjects to avoid bug where generalized or specialization could b...
  • Loading branch information
kerrizor committed Dec 19, 2014
2 parents d4f607e + e197e1d commit 7567f6f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/rails_erd/domain/specialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def abstract_from_models(domain, models)
attr_reader :specialized

def initialize(domain, generalized, specialized) # @private :nodoc:
@domain, @generalized, @specialized = domain, generalized, specialized
@domain = domain
@generalized = generalized || NullGeneralized.new
@specialized = specialized || NullSpecialization.new
end

def generalization?
Expand All @@ -66,5 +68,17 @@ def <=>(other) # @private :nodoc:
(generalized.name <=> other.generalized.name).nonzero? or (specialized.name <=> other.specialized.name)
end
end

class NullSpecialization
def name
""
end
end

class NullGeneralized
def name
""
end
end
end
end

0 comments on commit 7567f6f

Please sign in to comment.