class Promiscuous::BlackHole::StaleEmbeddingsDestroyer

Public Class Methods

new(table_name, parent_id) click to toggle source
# File lib/promiscuous_black_hole/stale_embeddings_destroyer.rb, line 3
def initialize(table_name, parent_id)
  @table_name = table_name
  @parent_id  = parent_id
end

Public Instance Methods

child_ids_for(table) click to toggle source
# File lib/promiscuous_black_hole/stale_embeddings_destroyer.rb, line 18
def child_ids_for(table)
  criteria_for(table).map(:id)
end
child_tables() click to toggle source
# File lib/promiscuous_black_hole/stale_embeddings_destroyer.rb, line 22
def child_tables
  DB[:embeddings].where('parent_table = ?', @table_name).map(:child_table)
end
process() click to toggle source
# File lib/promiscuous_black_hole/stale_embeddings_destroyer.rb, line 8
def process
  child_tables.each do |child_table|
    child_ids_for(child_table).each do |id|
      StaleEmbeddingsDestroyer.new(child_table, id).process
    end

    criteria_for(child_table).delete
  end
end

Private Instance Methods

criteria_for(table) click to toggle source
# File lib/promiscuous_black_hole/stale_embeddings_destroyer.rb, line 28
def criteria_for(table)
  DB[table].where('embedded_in_id = ?', @parent_id)
end