Overriding XMLHttpRequest.open()

You are not modifying the open method inherited by XMLHttpRequest objects but just adding a method to the XMLHttpRequest constructor which is actually never used. I tried this code in facebook and I was able to catch the requests: (function() { var proxied = window.XMLHttpRequest.prototype.open; window.XMLHttpRequest.prototype.open = function() { console.log( arguments ); return proxied.apply(this, [].slice.call(arguments)); … Read more

What is the right way to override a setter method in Ruby on Rails?

=========================================================================== Update: July 19, 2017 Now the Rails documentation is also suggesting to use super like this: class Model < ActiveRecord::Base def attribute_name=(value) # custom actions ### super(value) end end =========================================================================== Original Answer If you want to override the setter methods for columns of a table while accessing through models, this is the way to … Read more

JavaScript override methods

Edit: It’s now six years since the original answer was written and a lot has changed! If you’re using a newer version of JavaScript, possibly compiled with a tool like Babel, you can use real classes. If you’re using the class-like component constructors provided by Angular or React, you’ll want to look in the docs … Read more

Type erasure, overriding and generics

The signature of fooMethod(Class<?>) is the same as the signature of fooMethod(Class) after erasure, since the erasure of Class<?> is simply Class (JLS 4.6). Hence, fooMethod(Class) is a subsignature of the fooMethod(Class<?>) but not the opposite (JLS 8.4.2). For overriding with instance methods you need the overriding method to be a subsignature of the overridden … Read more