Skip to content

Commit

Permalink
Ruby 1.8.7 does not have a singleton class, so removing it.
Browse files Browse the repository at this point in the history
  • Loading branch information
barttenbrinke committed Mar 22, 2013
1 parent 7624be2 commit 2903da9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/brakeman/report/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ class Brakeman::Report
class Renderer
def initialize(template_file, hash = {})
hash[:locals] ||= {}
hash[:locals].each do |key, value|
singleton_class.send(:define_method, key) { value }
end
singleton = class << self; self end

singleton_class.send(:define_method, 'template_file') { template_file }
hash[:locals].each do |attribute_name, attribute_value|
singleton.send(:define_method, attribute_name) { attribute_value }
end

singleton_class.send(:define_method, 'template') {
# 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.expand_path("templates/#{template_file}.html.erb", File.dirname(__FILE__)))
}
end
Expand Down

0 comments on commit 2903da9

Please sign in to comment.