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

Fix bug with model fragments support #185

Closed
wants to merge 1 commit into from
Closed

Fix bug with model fragments support #185

wants to merge 1 commit into from

Conversation

mattmcginnis
Copy link
Contributor

@@ -39,7 +39,8 @@ export default class {
if ('function' === typeof serializer.transformFor) {
// Use serializer.transformFor for compatibility with ember-data-model-fragments,
// for context see https://github.com/danielspaniel/ember-data-factory-guy/issues/182
return serializer.transformFor(type).serialize;
let fragmentType = serializer.transformFor(type);
return fragmentType.deserialize.bind(fragmentType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be return fragmentType.serialize.bind(fragmentType);?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am wondering if this should be a do nothing ( return (x)=>x ) kind of thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be return fragmentType.serialize.bind(fragmentType);?

Tried that and got "Cannot read property 'modelName' of undefined" on the last line of this snippet.

    /**
      Changes serializer fallbacks for fragments to use `serializer:-fragment`
      if registered, then uses the default serializer.
       @method serializerFor
      @private
      @param {String} modelName the record to serialize
      @return {DS.Serializer}
    */
    serializerFor: function serializerFor(modelOrClass) {
      var modelName;

      if (typeof modelOrClass === 'string') {
        modelName = modelOrClass;
      } else {
        modelName = modelOrClass.modelName;
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, if I just return this.noTransformFn, all my tests pass in the sample repo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that is what I was saying about the (x)=> x .. function = noTransformFn.
I think that is the correct answer .. but I want to get more tests in there and if you can help with that .. then rock on.
Need to know more about MF transformations and when they are used.

@danielspaniel
Copy link
Collaborator

This issue should now be fixed with version 2.5 ( which has full support for ember-data-model-fragments )

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