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(context:, 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(context:, name:, partial: true)
  @context = context
  @name = name
  @partial = partial
  @ids = Set.new
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#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

#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
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 15

def copy_statement
  if partial
    "select * from #{name} where id in (#{ids.to_a.join(',')})"
  else
    "select * from #{name}"
  end
end

#fetch_associations(directive) ⇒ Object



23
24
25
26
27
# File 'lib/table_saw/dependency_graph/dump_table.rb', line 23

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