Class: DynamicModel::RelationsAnalyser
- Inherits:
-
Object
- Object
- DynamicModel::RelationsAnalyser
- Defined in:
- lib/database_introspection/dynamic_model/relations_analyser.rb
Overview
This class is in charge to analyse the relationships between the tables of the domain. It will then add association methods to the classes.
Constant Summary collapse
- KEY_IDENTIFIER =
/_id$/
Instance Attribute Summary collapse
-
#alterations ⇒ Object
readonly
.
Instance Method Summary collapse
-
#initialize(klasses) ⇒ RelationsAnalyser
constructor
A new instance of RelationsAnalyser.
- #run ⇒ Object
Constructor Details
#initialize(klasses) ⇒ RelationsAnalyser
Returns a new instance of RelationsAnalyser.
11 12 13 14 |
# File 'lib/database_introspection/dynamic_model/relations_analyser.rb', line 11 def initialize(klasses) @klasses = klasses @alterations = {} end |
Instance Attribute Details
#alterations ⇒ Object (readonly)
9 10 11 |
# File 'lib/database_introspection/dynamic_model/relations_analyser.rb', line 9 def alterations @alterations end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/database_introspection/dynamic_model/relations_analyser.rb', line 16 def run raise "cannot rerun analysis with the same object... Create a new instance !" if @did_run return if @klasses.empty? @domain = @klasses[0].domain introspect_belongs_to verify_if_has_many_relations_could_be_actually_has_one discover_has_many_through_from_belongs_to apply_alterations @did_run = true end |