-
-
Save bendrucker/8523364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActualModel = ModelBase.extend({ | |
related: function() {this.hasOne(OtherModel);} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ModelBase = Model.extend({ | |
hasOne: function(Model, fkey) { | |
Model.prototype.hasOne.call(this, Model, 'myconstantforeignkey') | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.each(['hasMany', 'hasOne', 'belongsToMany', 'morphOne', 'morphMany', 'belongsTo', 'through'], function(method) { | |
var original = Model.prototype[method] | |
Model.prototype[method] = function() { | |
// Stuff here | |
return original.apply(this, ...) | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As far-fetched as this example is, it is technically broken