Class: Brakeman::Report::Renderer
- Inherits:
-
Object
- Object
- Brakeman::Report::Renderer
- Defined in:
- lib/brakeman/report/renderer.rb
Instance Method Summary collapse
-
#initialize(template_file, hash = {}) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(template_file, hash = {}) ⇒ Renderer
Returns a new instance of Renderer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/brakeman/report/renderer.rb', line 5 def initialize(template_file, hash = {}) hash[:locals] ||= {} singleton = class << self; self end hash[:locals].each do |attribute_name, attribute_value| singleton.send(:define_method, attribute_name) { attribute_value } end # There are last, so as to make overwriting these using locals impossible. singleton.send(:define_method, 'template_file') { template_file } singleton.send(:define_method, 'template') { File.read(File.("templates/#{template_file}.html.erb", File.dirname(__FILE__))) } end |
Instance Method Details
#render ⇒ Object
20 21 22 |
# File 'lib/brakeman/report/renderer.rb', line 20 def render ERB.new(template).result(binding) end |