Class: Lhm::ChunkInsert
- Inherits:
-
Object
- Object
- Lhm::ChunkInsert
- Defined in:
- lib/lhm/chunk_insert.rb
Constant Summary collapse
- LOG_PREFIX =
"ChunkInsert"
Instance Method Summary collapse
- #bottom ⇒ Object
- #expected_rows ⇒ Object
-
#initialize(migration, connection, lowest, highest, options = {}) ⇒ ChunkInsert
constructor
A new instance of ChunkInsert.
- #insert_and_return_count_of_rows_created ⇒ Object
- #top ⇒ Object
Constructor Details
#initialize(migration, connection, lowest, highest, options = {}) ⇒ ChunkInsert
Returns a new instance of ChunkInsert.
9 10 11 12 13 14 15 |
# File 'lib/lhm/chunk_insert.rb', line 9 def initialize(migration, connection, lowest, highest, = {}) @migration = migration @connection = connection @lowest = lowest @highest = highest @options = end |
Instance Method Details
#bottom ⇒ Object
21 22 23 |
# File 'lib/lhm/chunk_insert.rb', line 21 def bottom @lowest end |
#expected_rows ⇒ Object
29 30 31 |
# File 'lib/lhm/chunk_insert.rb', line 29 def expected_rows @options.fetch(:expected_rows, top - bottom + 1) end |
#insert_and_return_count_of_rows_created ⇒ Object
17 18 19 |
# File 'lib/lhm/chunk_insert.rb', line 17 def insert_and_return_count_of_rows_created @connection.update(sql, should_retry: true, log_prefix: LOG_PREFIX) end |
#top ⇒ Object
25 26 27 |
# File 'lib/lhm/chunk_insert.rb', line 25 def top @highest end |