Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Use Ember.assign() if possible #93

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
8 changes: 4 additions & 4 deletions addon/ajax-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const {
RSVP: { Promise },
get,
isNone,
merge,
run,
Test,
testing
} = Ember;
const assign = Ember.assign || Ember.merge;
const JSONAPIContentType = 'application/vnd.api+json';

function isJSONAPIContentType(header) {
Expand Down Expand Up @@ -200,8 +200,8 @@ export default class AjaxRequest {
*/
_getFullHeadersHash(headers) {
const classHeaders = get(this, 'headers') || {};
const _headers = merge({}, classHeaders);
return merge(_headers, headers);
const _headers = assign({}, classHeaders);
Copy link
Member

Choose a reason for hiding this comment

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

assign allows more than two arguments so we should be able to do this in a single invocation:

return assign({}, classHeaders, headers);

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, but we can't do that until we can require v2.5.0, 😿

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rwjblue yep, assign could be Ember.merge. :trollface:

return assign(_headers, headers);
}

/**
Expand Down Expand Up @@ -520,7 +520,7 @@ export default class AjaxRequest {
}

return payload.errors.map(function(error) {
let ret = merge({}, error);
let ret = assign({}, error);

if (typeof ret.status === 'number') {
ret.status = `${ret.status}`;
Expand Down