Module: RailsGraph::Helpers::Associations

Defined in:
lib/rails_graph/helpers/associations.rb

Class Method Summary collapse

Class Method Details

.source_identifier(association) ⇒ Object



8
9
10
# File 'lib/rails_graph/helpers/associations.rb', line 8

def source_identifier(association)
  RailsGraph::Helpers::Models.identifier(association.active_record)
end

.source_node(graph, association) ⇒ Object



12
13
14
15
16
# File 'lib/rails_graph/helpers/associations.rb', line 12

def source_node(graph, association)
  identifier = source_identifier(association)

  graph.node(identifier)
end

.target_identifier(association) ⇒ Object



18
19
20
21
22
# File 'lib/rails_graph/helpers/associations.rb', line 18

def target_identifier(association)
  return "PolymorphicModel" if association.polymorphic?

  RailsGraph::Helpers::Models.identifier(association.klass)
end

.target_node(graph, association) ⇒ Object



24
25
26
27
28
# File 'lib/rails_graph/helpers/associations.rb', line 24

def target_node(graph, association)
  identifier = target_identifier(association)

  graph.node(identifier)
end