Class: TableSaw::DependencyGraph::DumpTable

Inherits:
Object
  • Object
show all
Defined in:
lib/table_saw/dependency_graph/dump_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest:, name:, partial: true) ⇒ DumpTable

Returns a new instance of DumpTable.



8
9
10
11
12
13
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 8

def initialize(manifest:, name:, partial: true)
  @manifest = manifest
  @name = name
  @partial = partial
  @ids = Set.new
end

Instance Attribute Details

#idsObject (readonly)

Returns the value of attribute ids.



6
7
8
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 6

def ids
  @ids
end

#manifestObject (readonly)

Returns the value of attribute manifest.



6
7
8
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 6

def manifest
  @manifest
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 6

def name
  @name
end

#partialObject (readonly)

Returns the value of attribute partial.



6
7
8
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 6

def partial
  @partial
end

Instance Method Details

#copy_statementObject



15
16
17
18
19
20
21
22
23
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 15

def copy_statement
  if partial
    format 'select * from %{name} where %{clause}',
           name:, clause: TableSaw::Queries::SerializeSqlInClause.new(name, primary_key, ids.to_a).call

  else
    "select * from #{name}"
  end
end

#fetch_associations(directive) ⇒ Object



25
26
27
28
29
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 25

def fetch_associations(directive)
  directive.ids = directive.ids - ids.to_a
  ids.merge(directive.ids)
  fetch_belongs_to(directive) + fetch_has_many(directive)
end