class RomSqlGraph::Edges

Constants

SQL

Attributes

relations[R]

Public Class Methods

new(repo) click to toggle source
# File lib/rom_sql_graph/edges.rb, line 5
def initialize(repo)
  @relations = sql_relations(repo)
end

Public Instance Methods

to_a() click to toggle source
# File lib/rom_sql_graph/edges.rb, line 9
def to_a
  relations.map do |name, relation|
    relation.schema.associations.elements.map do |_, object|
      association_name = Inflecto.pluralize(object.target.to_sym.to_s).to_sym
      [name, association_name]
    end
  end.map! { |array| array.empty? ? nil : array }.compact.flatten(1)
end

Private Instance Methods

sql_relations(repo) click to toggle source
# File lib/rom_sql_graph/edges.rb, line 22
def sql_relations(repo)
  repo.container.relations.elements
    .select { |name, object| object.class.adapter == SQL }
end