Class: TableSaw::DependencyGraph::DumpTable
- Inherits:
-
Object
- Object
- TableSaw::DependencyGraph::DumpTable
- Defined in:
- lib/table_saw/dependency_graph/dump_table.rb
Instance Attribute Summary collapse
-
#ids ⇒ Object
readonly
Returns the value of attribute ids.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#partial ⇒ Object
readonly
Returns the value of attribute partial.
Instance Method Summary collapse
- #copy_statement ⇒ Object
- #fetch_associations(directive) ⇒ Object
-
#initialize(manifest:, name:, partial: true) ⇒ DumpTable
constructor
A new instance of DumpTable.
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
#ids ⇒ Object (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 |
#manifest ⇒ Object (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 |
#name ⇒ Object (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 |
#partial ⇒ Object (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_statement ⇒ Object
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 |