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

Projects
None yet
2 participants
@gmajoulet
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@PaulUithol

PaulUithol Jul 9, 2013

Owner

What would you use this for?

Owner

PaulUithol commented Jul 9, 2013

What would you use this for?

@gmajoulet

This comment has been minimized.

Show comment
Hide comment
@gmajoulet

gmajoulet Jul 10, 2013

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@gmajoulet

gmajoulet Jul 17, 2013

Contributor

Any update on this small improvement?

Contributor

gmajoulet commented Jul 17, 2013

Any update on this small improvement?

@PaulUithol

This comment has been minimized.

Show comment
Hide comment
@PaulUithol

PaulUithol Jul 24, 2013

Owner

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.

Owner

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

This comment has been minimized.

Show comment
Hide comment
@gmajoulet

gmajoulet Jul 24, 2013

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@gmajoulet

gmajoulet Jul 28, 2013

Contributor

Done!

Thanks

Contributor

gmajoulet commented Jul 28, 2013

Done!

Thanks

PaulUithol added a commit that referenced this pull request Aug 5, 2013

Merge pull request #370 from gmajoulet/master
Relations can now be a method or a property

@PaulUithol PaulUithol merged commit 78dfc2b into PaulUithol:master Aug 5, 2013

@PaulUithol

This comment has been minimized.

Show comment
Hide comment
@PaulUithol

PaulUithol Jan 16, 2014

Owner

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.

Owner

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