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

Relations can now be a method or a property #370

Merged
merged 1 commit into from Aug 5, 2013

Conversation

@gmajoulet
Copy link
Contributor

@gmajoulet gmajoulet commented Jun 25, 2013

You have now 2 ways to declare a relation :

{
    relations: []
}

or

{
    relations: function () {
        return [];
    }
}

(I also removed trailing spaces)

@PaulUithol
Copy link
Owner

@PaulUithol PaulUithol commented Jul 9, 2013

What would you use this for?

@gmajoulet
Copy link
Contributor Author

@gmajoulet gmajoulet commented Jul 10, 2013

It becomes easier to override if you use an interface.
That's how they're doing it in Backbone, it lets the developper override property the same way if they're either from Backbone or from Backbone relational

Example for the "events" Backbone property : https://github.com/jashkenas/backbone/blob/master/backbone.js#L1064

@gmajoulet
Copy link
Contributor Author

@gmajoulet gmajoulet commented Jul 17, 2013

Any update on this small improvement?

@PaulUithol
Copy link
Owner

@PaulUithol PaulUithol commented Jul 24, 2013

I would merge it right away if you could provide a patch without all the other changes (removing whitespace), since that will cause merge conflicts on (most) other pull requests. I'd rather do that some other time myself.

@gmajoulet
Copy link
Contributor Author

@gmajoulet gmajoulet commented Jul 24, 2013

Ok, I'll do that asap. Thanks

Le 24 juil. 2013 à 14:57, Paul Uithol notifications@github.com a écrit :

I would merge it right away if you could provide a patch without all the other changes (removing whitespace), since that will cause merge conflicts on (most) other pull requests. I'd rather do that some other time myself.


Reply to this email directly or view it on GitHub.

@gmajoulet
Copy link
Contributor Author

@gmajoulet gmajoulet commented Jul 28, 2013

Done!

Thanks

PaulUithol added a commit that referenced this issue Aug 5, 2013
Relations can now be a method or a property
@PaulUithol PaulUithol merged commit 78dfc2b into PaulUithol:master Aug 5, 2013
@PaulUithol
Copy link
Owner

@PaulUithol PaulUithol commented Jan 16, 2014

Sorry, had to take this out.. this breaks with submodels. We directly modify the relations array in a couple of places, which is not possible when it's defined as a function. The only way around this would be to directly execute (and store) the function's results whenever we first encounter a model.. but that may be defeating the purpose of having a function in the first place.

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

Successfully merging this pull request may close these issues.

None yet

2 participants