Class: Lhm::ChunkFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/lhm/chunk_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(migration, connection = nil, options = {}) ⇒ ChunkFinder

Returns a new instance of ChunkFinder.



3
4
5
6
7
8
# File 'lib/lhm/chunk_finder.rb', line 3

def initialize(migration, connection = nil, options = {})
  @migration = migration
  @connection = connection
  @start = options[:start] || select_start_from_db
  @limit = options[:limit] || select_limit_from_db
end

Instance Attribute Details

#limitObject

Returns the value of attribute limit.



10
11
12
# File 'lib/lhm/chunk_finder.rb', line 10

def limit
  @limit
end

#startObject

Returns the value of attribute start.



10
11
12
# File 'lib/lhm/chunk_finder.rb', line 10

def start
  @start
end

Instance Method Details

#table_empty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/lhm/chunk_finder.rb', line 12

def table_empty?
  start.nil? && limit.nil?
end

#validateObject



16
17
18
19
20
# File 'lib/lhm/chunk_finder.rb', line 16

def validate
  if start > limit
    raise ArgumentError, "impossible chunk options (limit (#{limit.inspect} must be greater than start (#{start.inspect})"
  end
end