Class: ThinreportsHandler::ThinreportsTemplate
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ThinreportsHandler::ThinreportsTemplate
- Defined in:
- lib/thinreports-handler/template_handler.rb
Instance Attribute Summary collapse
-
#_generate_options ⇒ Object
Returns the value of attribute _generate_options.
Instance Method Summary collapse
- #generate_options(options) ⇒ Object
-
#initialize(thinreports_report_base_obj, template_context, template_virtual_path) ⇒ ThinreportsTemplate
constructor
A new instance of ThinreportsTemplate.
- #partial!(options, locals = {}) ⇒ Object
- #search_tlf_path(virtual_path) ⇒ Object
- #set_layout(options = {}) ⇒ Object
Constructor Details
#initialize(thinreports_report_base_obj, template_context, template_virtual_path) ⇒ ThinreportsTemplate
Returns a new instance of ThinreportsTemplate.
10 11 12 13 14 |
# File 'lib/thinreports-handler/template_handler.rb', line 10 def initialize(thinreports_report_base_obj, template_context, template_virtual_path) @_template_context = template_context @_template_virtual_path = template_virtual_path super(thinreports_report_base_obj) end |
Instance Attribute Details
#_generate_options ⇒ Object
Returns the value of attribute _generate_options.
8 9 10 |
# File 'lib/thinreports-handler/template_handler.rb', line 8 def @_generate_options end |
Instance Method Details
#generate_options(options) ⇒ Object
31 32 33 |
# File 'lib/thinreports-handler/template_handler.rb', line 31 def () self. = end |
#partial!(options, locals = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/thinreports-handler/template_handler.rb', line 16 def partial!(, locals = {}) case when Hash [:locals] ||= {} [:locals].merge!(:report => self) @_template_context.render() else @_template_context.render(, locals.merge(:report => self)) end end |
#search_tlf_path(virtual_path) ⇒ Object
27 28 29 |
# File 'lib/thinreports-handler/template_handler.rb', line 27 def search_tlf_path(virtual_path) "#{virtual_path || @_template_virtual_path}.tlf" end |
#set_layout(options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/thinreports-handler/template_handler.rb', line 35 def set_layout( = {}) = ? .dup: {} tlf_path = search_tlf_path([:tlf]) ActionController::Base.view_paths.each do |view_path| full_path = File.join(view_path.to_s, tlf_path) if File.exist?(full_path) return self.use_layout(full_path, *([[:layout_options]].compact)) end end raise("#{tlf_path} not found.") end |