Is there a clean way I can know if given object is 'restangularized'?
See original GitHub issueHi. Basically, I have situation where I have to know if object passed to the function is restangularized or not, it might be a collection or a single element.
I was thinking about two options.
First option, adding isRestangularized
boolean property to each response via RestangularProvider.setResponseExtractor()
However, there is a problem with it, object can ‘by pass’ intercepter, for instance I can create restangularized element using Restangular.restangularizeElement()
and it will not contain my isRestangularized
property.
As second option, I can look for restangular properties that exist both in collections and elements such as addRestangularMethod
by doing object.hasOwnProperty('addRestangularMethod')
check.
Is there a better way? (using 1.4.0 version of Restangular)
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
AFAIK there’s a
restangularized
boolean property already. You can check for it.Sorry I was wrong. Using Restangular 1.5.2, I have the field
restangularized
.