Class: ActiveRecordGraphExtractor::DryRunAnalyzer
- Inherits:
-
Object
- Object
- ActiveRecordGraphExtractor::DryRunAnalyzer
- Defined in:
- lib/activerecord_graph_extractor/dry_run_analyzer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model_count_cache ⇒ Object
readonly
Returns the value of attribute model_count_cache.
-
#relationship_analyzer ⇒ Object
readonly
Returns the value of attribute relationship_analyzer.
-
#relationship_count_cache ⇒ Object
readonly
Returns the value of attribute relationship_count_cache.
-
#sample_record_cache ⇒ Object
readonly
Returns the value of attribute sample_record_cache.
Instance Method Summary collapse
- #analyze(root_objects, options = {}) ⇒ Object
-
#initialize(config = ActiveRecordGraphExtractor.configuration) ⇒ DryRunAnalyzer
constructor
A new instance of DryRunAnalyzer.
Constructor Details
#initialize(config = ActiveRecordGraphExtractor.configuration) ⇒ DryRunAnalyzer
Returns a new instance of DryRunAnalyzer.
7 8 9 10 11 12 13 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 7 def initialize(config = ActiveRecordGraphExtractor.configuration) @config = config @relationship_analyzer = RelationshipAnalyzer.new(config) @model_count_cache = {} # Cache for model.count queries @relationship_count_cache = {} # Cache for relationship count estimates @sample_record_cache = {} # Cache for sample records end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 5 def config @config end |
#model_count_cache ⇒ Object (readonly)
Returns the value of attribute model_count_cache.
5 6 7 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 5 def model_count_cache @model_count_cache end |
#relationship_analyzer ⇒ Object (readonly)
Returns the value of attribute relationship_analyzer.
5 6 7 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 5 def relationship_analyzer @relationship_analyzer end |
#relationship_count_cache ⇒ Object (readonly)
Returns the value of attribute relationship_count_cache.
5 6 7 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 5 def relationship_count_cache @relationship_count_cache end |
#sample_record_cache ⇒ Object (readonly)
Returns the value of attribute sample_record_cache.
5 6 7 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 5 def sample_record_cache @sample_record_cache end |
Instance Method Details
#analyze(root_objects, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/activerecord_graph_extractor/dry_run_analyzer.rb', line 15 def analyze(root_objects, = {}) raise ExtractionError, "Root object cannot be nil" if root_objects.nil? root_objects = Array(root_objects) # Validate that all objects are ActiveRecord instances root_objects.each do |obj| unless obj.is_a?(ActiveRecord::Base) raise ExtractionError, "Object must be an ActiveRecord object, got #{obj.class}" end end # Extract options max_depth = [:max_depth] || config.max_depth start_time = Time.now begin # Analyze the object graph without loading data analysis_result = analyze_object_graph(root_objects, max_depth) analysis_time = Time.now - start_time # Build comprehensive analysis report build_analysis_report(analysis_result, analysis_time, root_objects, max_depth) rescue StandardError => e raise ExtractionError, "Failed to analyze object graph: #{e.}" end end |