angular-restmod
angular-restmod copied to clipboard
$send is not accessible anymore
I have a model that defines a 'non-restful' method like:
var model = restmod.model('api/settings').$mix({
"@loginBanner": function(){
return this.$send({
url: this.$url() + '/login-banner',
method: 'GET'
});
}
});
after updating to latest version, $send
is not accessible on this
, I have to do this.prototype
? ... any thoughts on better usage?
I noticed in some sample code that you can do this.$collection().$send()
. I am not really sure what the difference is, though...
The common api is not accesible as static methods anymore, this is because the common api is not stateless and static methods should be stateless. I'm working on a small refactoring to provide a way of generating blank objects (not records nor collections) to be able to generate custom requests related to the model but not to any collection or record.
About the @loginBanner
method, I think you should consider using a singleton model with relations instead of a custom actions, like this:
var settings = restmod.model().$mix({
loginBanner: { hasMany: restmod.model(), path: 'login-banner' }
}).$single('api/settings');
// Then do
settings.loginBanner.$fetch();
That seems odd to me :S.
Problem is: I have several of these cases where I need 'one off' methods that don't fall into the standard restful method procedures.