Module: Dbwatcher::Storage::Api::Concerns::TableAnalyzer

Included in:
SessionAPI
Defined in:
lib/dbwatcher/storage/api/concerns/table_analyzer.rb

Overview

Provides reusable table analysis functionality for API classes

This concern now acts as a facade, delegating specific responsibilities to specialized service classes while maintaining backward compatibility.

Examples:

class MyAPI < BaseAPI
  include Api::Concerns::TableAnalyzer

  def analyze(session)
    build_tables_summary(session)
  end
end

Instance Method Summary collapse

Instance Method Details

#build_tables_summary(session) ⇒ Hash

Build tables summary from session changes

Parameters:

  • session (Session)

    session to analyze

Returns:

  • (Hash)

    tables summary hash



25
26
27
28
# File 'lib/dbwatcher/storage/api/concerns/table_analyzer.rb', line 25

def build_tables_summary(session)
  # Delegate to new service while maintaining interface compatibility
  Dbwatcher::Services::Analyzers::TableSummaryBuilder.new(session).call
end

#extract_table_name(change) ⇒ String?

Extract table name from change data (legacy compatibility)

Parameters:

  • change (Hash)

    change data

Returns:

  • (String, nil)

    table name or nil



50
51
52
53
54
# File 'lib/dbwatcher/storage/api/concerns/table_analyzer.rb', line 50

def extract_table_name(change)
  return nil unless change.is_a?(Hash)

  change[:table_name]
end

#process_session_changes(session, _tables) ⇒ void

This method returns an undefined value.

Process all changes in a session (legacy method for backward compatibility)

Parameters:

  • session (Session)

    session with changes

  • _tables (Hash)

    tables hash to populate (unused but kept for compatibility)



35
36
37
38
39
40
41
# File 'lib/dbwatcher/storage/api/concerns/table_analyzer.rb', line 35

def process_session_changes(session, _tables)
  # Use new service for processing but maintain yield interface
  processor = Dbwatcher::Services::Analyzers::SessionDataProcessor.new(session)
  processor.process_changes do |table_name, change, _|
    yield(table_name, change) if block_given?
  end
end