Class: Ruby::Reports::Services::DataIterator

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/reports/services/data_iterator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#custom_sourceObject (readonly)

Returns the value of attribute custom_source.



5
6
7
# File 'lib/ruby/reports/services/data_iterator.rb', line 5

def custom_source
  @custom_source
end

Instance Method Details

#data_each(force = false, &block) ⇒ Object

Internal: Выполняет запрос строк отчета пачками

Returns Nothing



18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby/reports/services/data_iterator.rb', line 18

def data_each(force = false, &block)
  return iterate_custom_source(&block) if custom_source

  batch_offset = 0

  while (rows = query.request_batch(batch_offset)).count > 0 do
    rows.each { |row| yield row }
    batch_offset += config.batch_size
  end
end

#data_sizeObject

Internal: Возвращает общее кол-во строк в отчете

Returns Fixnum



32
33
34
35
36
37
38
# File 'lib/ruby/reports/services/data_iterator.rb', line 32

def data_size
  @data_size ||= if custom_source
                   custom_source.count
                 else
                   query.request_count
                 end
end

#iterate_custom_sourceObject



10
11
12
13
14
# File 'lib/ruby/reports/services/data_iterator.rb', line 10

def iterate_custom_source
  custom_source.each do |row|
    yield row
  end
end