Skip to content

wrapWith method in Model#11

Closed
retro wants to merge 1 commit intojupiterjs:masterfrom
retro:master
Closed

wrapWith method in Model#11
retro wants to merge 1 commit intojupiterjs:masterfrom
retro:master

Conversation

@retro
Copy link
Contributor

@retro retro commented Dec 17, 2010

I've added wrapWith method to model that enables simpler inheritance for subclasses. I believe that wrap method shouldn't be overridden as it holds important functionality. This way user only has to overwrite wrapWith method that should return existing class.

It would be used like this:

$.Model.extend("Animal",{
  wrapWith: function( attrs ) {
        if(attrs.animal_type == 'dog') return Dog;
    if(attrs.animal_type == 'cat') return Cat;
    return this;
  } 
  },{}
});

@tdreyno
Copy link
Contributor

tdreyno commented Dec 29, 2010

I like this patch a lot!

I'm going to check with the guys, since I'm still nervous about committing directly to the main repo myself.

@retro
Copy link
Contributor Author

retro commented Dec 29, 2010

Yeah, I have pull privileges too, but would like if someone else would pull these changes.

@jupiterjs
Copy link
Collaborator

meaning me it seems. I think either one of you can pull this if it's tested.

This pull request was closed.
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

Successfully merging this pull request may close these issues.

3 participants