Class: Reportinator::ModelReport
Constant Summary
collapse
- PARSE_PARAMS =
false
Instance Attribute Summary
Attributes inherited from ReportType
#metadata
Instance Method Summary
collapse
Methods included from Helpers
#merge_hash, #merge_hash!, #symbolize_attributes
Methods inherited from ReportType
#error_message, generate, #generate_csv, generate_to_csv, #report_title
Methods inherited from Base
config, #config, logger, #logger
Instance Method Details
#data ⇒ Object
10
11
12
13
14
|
# File 'lib/reportinator/types/model.rb', line 10
def data
self.target = ValueParser.parse(target, metadata, false)
return Row.create(get_model_data(target)) unless target.respond_to? :each
records_data.map { |data| Row.create(data) }
end
|
#get_model_data(target) ⇒ Object
25
26
27
28
29
|
# File 'lib/reportinator/types/model.rb', line 25
def get_model_data(target)
method_list.map do |method|
parse_method(target, method)
end
end
|
#parse_method(target, method) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/reportinator/types/model.rb', line 31
def parse_method(target, method)
parser_metadata = merge_hash(metadata, {variables: {target: target}})
parsed_method = ValueParser.parse(method, parser_metadata)
return parsed_method if parsed_method.instance_of? String
MethodParser.parse(target, parsed_method)
end
|
#records_data ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/reportinator/types/model.rb', line 16
def records_data
output = []
target.each do |model|
value = get_model_data(model)
output << value
end
output
end
|