module Rails::AngularXSS

Public Class Methods

redef_without_warning(const, value, expected: nil) click to toggle source
# File lib/rails/angular-xss.rb, line 6
def self.redef_without_warning(const, value, expected: nil)
  old_value = ERB::Util.const_get(const)
  if expected &&  old_value != expected
    raise "Trying to patch constant #{const}, but expected values have changed." \
          "#{old_value} != #{expected}"
  end

  ERB::Util.send(:remove_const, const)
  ERB::Util.send(:const_set, const, value)
end