Class: RomSqlGraph::Edges
- Inherits:
-
Object
- Object
- RomSqlGraph::Edges
- Defined in:
- lib/rom_sql_graph/edges.rb
Instance Attribute Summary collapse
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
Instance Method Summary collapse
-
#initialize(repo) ⇒ Edges
constructor
A new instance of Edges.
- #to_a ⇒ Object
Constructor Details
#initialize(repo) ⇒ Edges
Returns a new instance of Edges.
5 6 7 |
# File 'lib/rom_sql_graph/edges.rb', line 5 def initialize(repo) @relations = sql_relations(repo) end |
Instance Attribute Details
#relations ⇒ Object (readonly)
Returns the value of attribute relations.
3 4 5 |
# File 'lib/rom_sql_graph/edges.rb', line 3 def relations @relations end |
Instance Method Details
#to_a ⇒ Object
9 10 11 12 13 14 15 16 |
# 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 |