Class: RealDataTests::RecordCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/real_data_tests/record_collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ RecordCollector

Returns a new instance of RecordCollector.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/real_data_tests/record_collector.rb', line 5

def initialize(record)
  @record = record
  @collected_records = Set.new
  @collection_stats = {}
  @processed_associations = Set.new
  @association_path = []
  @current_depth = 0
  @visited_associations = {}
  @processed_self_refs = Hash.new { |h, k| h[k] = Set.new }

  init_collection_stats(record)
end

Instance Attribute Details

#collected_recordsObject (readonly)

Returns the value of attribute collected_records.



3
4
5
# File 'lib/real_data_tests/record_collector.rb', line 3

def collected_records
  @collected_records
end

#collection_statsObject (readonly)

Returns the value of attribute collection_stats.



3
4
5
# File 'lib/real_data_tests/record_collector.rb', line 3

def collection_stats
  @collection_stats
end

Instance Method Details

#collectObject



18
19
20
21
22
23
24
25
26
# File 'lib/real_data_tests/record_collector.rb', line 18

def collect
  puts "\nStarting record collection from: #{@record.class.name}##{@record.id}"
  filter_mode = RealDataTests.configuration.current_preset.association_filter_mode
  filter_list = RealDataTests.configuration.current_preset.association_filter_list
  puts "Using #{filter_mode || 'no'} filter with #{filter_list.any? ? filter_list.join(', ') : 'no associations'}"
  collect_record(@record, 0)
  print_collection_stats
  @collected_records.to_a
end