Class: MermaidRailsErd::RelationshipBuilders::HasManyRelationshipBuilder
- Inherits:
-
BaseRelationshipBuilder
- Object
- BaseRelationshipBuilder
- MermaidRailsErd::RelationshipBuilders::HasManyRelationshipBuilder
- Defined in:
- lib/mermaid_rails_erd/relationship_builders/has_many_relationship_builder.rb
Instance Attribute Summary
Attributes inherited from BaseRelationshipBuilder
#association_resolver, #model_data_collector, #symbol_mapper
Instance Method Summary collapse
Methods inherited from BaseRelationshipBuilder
Constructor Details
This class inherits a constructor from MermaidRailsErd::RelationshipBuilders::BaseRelationshipBuilder
Instance Method Details
#build(model, assoc) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mermaid_rails_erd/relationship_builders/has_many_relationship_builder.rb', line 8 def build(model, assoc) from_table = model.table_name fk = safe_foreign_key(model, assoc) # Skip if we couldn't determine the foreign key return [] unless fk to_table_info = resolve_association_model(model, assoc) if to_table_info # FK is on target table for has_many [Relationship.new( to_table_info[:table_name], from_table, fk, "}o--||", nil, # Let the Relationship generate the label to_table_info[:table_name], # fk_table fk, # fk_column from_table, # pk_table model.primary_key, # pk_column )] else log_missing_table_warning(model, assoc) end end |