Module: RailsERD::Diagram::Graphviz::Uml

Includes:
Simple
Defined in:
lib/rails_erd/diagram/graphviz.rb

Instance Method Summary collapse

Methods included from Simple

#entity_style, #specialization_style

Instance Method Details

#relationship_style(relationship) ⇒ Object


161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/rails_erd/diagram/graphviz.rb', line 161

def relationship_style(relationship)
  {}.tap do |options|
    options[:style] = :dotted if relationship.indirect?

    options[:arrowsize] = 0.7
    options[:arrowhead] = relationship.to_many? ? "vee" : "none"
    options[:arrowtail] = relationship.many_to? ? "vee" : "none"

    ranges = [relationship.cardinality.destination_range, relationship.cardinality.source_range].map do |range|
      if range.min == range.max
        "#{range.min}"
      else
        "#{range.min}..#{range.max == Domain::Relationship::N ? "" : range.max}"
      end
    end
    options[:headlabel], options[:taillabel] = *ranges
  end
end