define('ember-resource-metadata/adapter-mixin', ['exports'], function (exports) {
  'use strict';

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = Ember.Mixin.create({
    _resourceMetadata: Ember.inject.service('resource-metadata'),

    _correlateMetadata: function _correlateMetadata(record, fn) {
      var _this = this;

      return fn().then(function (response) {
        if (Array.isArray(response.data)) {
          response.data.forEach(function (hash) {
            return _this._correlateResource(record, hash);
          });
        } else {
          _this._correlateResource(record, response.data);
        }
        return response;
      });
    },
    _correlateResource: function _correlateResource(record, hash) {
      if (hash.meta) {
        var service = this.get('_resourceMetadata');
        if (record) {
          service.write(record, hash.meta);
        } else {
          service.write({ id: hash.id, type: hash.type }, hash.meta);
        }
      }
    },
    createRecord: function createRecord(store, type, snapshot) {
      var _this2 = this;

      return this._correlateMetadata(snapshot.record, function () {
        return _this2._super(store, type, snapshot);
      });
    },
    updateRecord: function updateRecord(store, type, snapshot) {
      var _this3 = this;

      return this._correlateMetadata(snapshot.record, function () {
        return _this3._super(store, type, snapshot);
      });
    },
    findRecord: function findRecord(store, type, id, snapshot) {
      var _this4 = this;

      return this._correlateMetadata(snapshot.record, function () {
        return _this4._super(store, type, id, snapshot);
      });
    },
    queryRecord: function queryRecord(store, type, query) {
      var _this5 = this;

      if (query.disableResourceMetadata) {
        query = Object.assign({}, query);
        delete query.disableResourceMetadata;
        return this._super(store, type, query);
      }
      return this._correlateMetadata(null, function () {
        return _this5._super(store, type, query);
      });
    },
    query: function query(store, type, _query) {
      var _this6 = this;

      return this._correlateMetadata(null, function () {
        return _this6._super(store, type, _query);
      });
    }
  });
});