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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addon/converter/fixture-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
let container = Ember.getOwner ? Ember.getOwner(this.store) : this.store.container;
return container.lookup('transform:' + type).serialize;
Expand Down