Class: DataList

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/rails_data/data_list.rb

Direct Known Subclasses

DataExport, DataImport, DataRecord

Instance Method Summary collapse

Instance Method Details

#config_excelObject



39
40
41
# File 'app/models/rails_data/data_list.rb', line 39

def config_excel
  @config_excel ||= export_excel.to_s.safe_constantize
end

#config_paramsObject



29
30
31
32
33
# File 'app/models/rails_data/data_list.rb', line 29

def config_params
  hash = {}
  config_table.parameters.map { |p| hash[p] = nil }
  hash
end

#config_pdfObject



43
44
45
# File 'app/models/rails_data/data_list.rb', line 43

def config_pdf
  @config_pdf ||= export_pdf.to_s.safe_constantize
end

#config_tableObject



35
36
37
# File 'app/models/rails_data/data_list.rb', line 35

def config_table
  @config_table ||= data_table.to_s.safe_constantize
end

#form_parametersObject



17
18
19
20
21
22
23
# File 'app/models/rails_data/data_list.rb', line 17

def form_parameters
  r = parameters.map { |k, v| { key: k, value: v } }
  if r.blank?
    r = [{ key: nil, value: nil }]
  end
  Settings.new(r)
end

#rebuild!Object



13
14
15
# File 'app/models/rails_data/data_list.rb', line 13

def rebuild!
  self.save
end

#update_parametersObject



25
26
27
# File 'app/models/rails_data/data_list.rb', line 25

def update_parameters
  self.parameters = config_params
end