Class: Reportinator::Template
- Defined in:
- lib/reportinator/report/template.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
config, #config, logger, #logger
Methods included from Helpers
#merge_hash, #merge_hash!, #symbolize_attributes
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/reportinator/report/template.rb', line 3 def children @children end |
Class Method Details
.load(params = {}) ⇒ Object
9 10 11 12 |
# File 'lib/reportinator/report/template.rb', line 9 def self.load(params = {}) template = new(params) template.register end |
Instance Method Details
#parse(meta = {}, data = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/reportinator/report/template.rb', line 19 def parse( = {}, data = {}) output = [] = = merge_hash(, ) new_data = attributes.transform_keys { |key| key.to_sym } combine_data = merge_hash(new_data, data) if children.present? && children.respond_to?(:to_ary) children.each do |child| output += child.parse(, combine_data) do |combine_data, , | yield(combine_data, , ) end end else output << yield(combine_data, , ) end output end |
#register ⇒ Object
14 15 16 17 |
# File 'lib/reportinator/report/template.rb', line 14 def register return load_template if template.present? self end |