Class: Ruby::Reports::Services::DataIterator
- Inherits:
-
Object
- Object
- Ruby::Reports::Services::DataIterator
- Defined in:
- lib/ruby/reports/services/data_iterator.rb
Instance Attribute Summary collapse
-
#custom_source ⇒ Object
readonly
Returns the value of attribute custom_source.
Instance Method Summary collapse
-
#data_each(force = false, &block) ⇒ Object
Internal: Выполняет запрос строк отчета пачками.
-
#data_size ⇒ Object
Internal: Возвращает общее кол-во строк в отчете.
- #iterate_custom_source ⇒ Object
Instance Attribute Details
#custom_source ⇒ Object (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_size ⇒ Object
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_source ⇒ Object
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 |