VeryModel icon indicating copy to clipboard operation
VeryModel copied to clipboard

How to determine if model was created from a factory?

Open terinjokes opened this issue 9 years ago • 2 comments

What's the equivalent of foo instanceof Foo when using VeryModel?

The model instance stores a reference to the factory in __verymeta.model but this isn't exposed via the API.

terinjokes avatar May 09 '16 08:05 terinjokes

Having a method that accesses that would be a good way to go about it.

fritzy avatar May 19 '16 03:05 fritzy

What I've done so far is implement this, but would be awesome if it was built in:

MyModel.is = function (o) {
  if (o && o.__verymeta && o.__verymeta.model) {
    return o.__verymeta.model === this;
  }

  return false;
};

terinjokes avatar May 23 '16 17:05 terinjokes