Class: DataCacheService
- Inherits:
-
Object
- Object
- DataCacheService
- Includes:
- DataExportHelper
- Defined in:
- app/models/concerns/data_cache_service.rb
Instance Method Summary collapse
- #cache_table ⇒ Object
- #cache_table_items ⇒ Object
-
#initialize(table_list) ⇒ DataCacheService
constructor
A new instance of DataCacheService.
Methods included from DataExportHelper
#convert_parameters, #field_result, #footer_result, #header_result
Constructor Details
#initialize(table_list) ⇒ DataCacheService
Returns a new instance of DataCacheService.
4 5 6 7 8 9 |
# File 'app/models/concerns/data_cache_service.rb', line 4 def initialize(table_list) @table_list = table_list @data_list = @table_list.data_list @config_table = table_list.data_list.config_table convert_parameters(@table_list.parameters) end |
Instance Method Details
#cache_table ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/models/concerns/data_cache_service.rb', line 11 def cache_table @table_list.headers = header_result cache_table_items @table_list. = @table_list.done = true @table_list.save end |
#cache_table_items ⇒ Object
19 20 21 22 23 24 |
# File 'app/models/concerns/data_cache_service.rb', line 19 def cache_table_items @config_table.collection.call(@params).each_with_index do |object, index| row = field_result(object, index) @table_list.table_items.create(fields: row) end end |