Skip to content

Commit

Permalink
properly deprecate removed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaulagiri committed Feb 13, 2018
1 parent c828d75 commit 2d8abde
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
15 changes: 13 additions & 2 deletions addon/models/github-organization.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { hasMany } from 'ember-data/relationships';
import { deprecate } from '@ember/application/deprecations';
import { computed } from '@ember/object';

export default Model.extend({
login: attr('string'),
name: attr('string'),
avatarUrl: attr('string'),

members: hasMany('github-member', { inverse: null }),
repositories: hasMany('github-repository')
members: hasMany('github-member'),
repositories: hasMany('github-repository'),

githubUsers: computed('members.[]', function() {
deprecate('The githubUsers property on the github-organization model has been deprecated. Please use the members property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' });
return this.get('members');
}),
githubRepositories: computed('repositories.[]', function() {
deprecate('The githubRepositories property on the github-organization model has been deprecated. Please use the repositories property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' });
return this.get('repositories');
})
});
4 changes: 2 additions & 2 deletions addon/models/github-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default Model.extend({
publishedAt: attr('date'),

author: belongsTo('github-user', { inverse: null }),
user: computed(function() {
deprecate('The user property on the github-release model has been deprecated. Please use the author property.', false, { id: 'ember-data-github.release-author', until: '1.0.0' });
user: computed('author', function() {
deprecate('The user property on the github-release model has been deprecated. Please use the author property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' });
return this.get('author');
}),
repository: belongsTo('github-repository')
Expand Down
9 changes: 8 additions & 1 deletion addon/models/github-user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { hasMany } from 'ember-data/relationships';
import { deprecate } from '@ember/application/deprecations';
import { computed } from '@ember/object';

export default Model.extend({
login: attr('string'),
Expand All @@ -21,5 +23,10 @@ export default Model.extend({
email: attr('string'),
bio: attr('string'),

repositories: hasMany('github-repository')
repositories: hasMany('github-repository'),

githubRepositories: computed('repositories.[]', function() {
deprecate('The githubRepositories property on the github-user model has been deprecated. Please use the repositories property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' });
return this.get('repositories');
}),
});

0 comments on commit 2d8abde

Please sign in to comment.