lib/rails_erd/domain/specialization.rb in rails-erd-1.2.1 vs lib/rails_erd/domain/specialization.rb in rails-erd-1.2.2
- old
+ new
@@ -1,8 +1,8 @@
module RailsERD
class Domain
- # Describes the specialization of an entity. Specialized entites correspond
+ # Describes the specialization of an entity. Specialized entities correspond
# to inheritance or polymorphism. In Rails, specialization is referred to
# as single table inheritance, while generalization is referred to as
# polymorphism or abstract classes.
class Specialization
class << self
@@ -47,11 +47,13 @@
# The destination entity.
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?
generalized.generalized?
end
@@ -62,9 +64,21 @@
end
alias_method :inheritance?, :specialization?
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