Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to determine if model was created from a factory? #29

Open
terinjokes opened this issue May 9, 2016 · 2 comments
Open

How to determine if model was created from a factory? #29

terinjokes opened this issue May 9, 2016 · 2 comments

Comments

@terinjokes
Copy link
Contributor

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.

@fritzy
Copy link
Owner

fritzy commented May 19, 2016

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

@terinjokes
Copy link
Contributor Author

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;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants