diff --git a/addons/api/addon/generated/models/host.js b/addons/api/addon/generated/models/host.js index 0d9e0dd2d..8713b9b89 100644 --- a/addons/api/addon/generated/models/host.js +++ b/addons/api/addon/generated/models/host.js @@ -35,8 +35,4 @@ export default class GeneratedHostModel extends BaseModel { }) version; - @attr('string', { - description: 'The address (DNS or IP name) used to reach the host' - }) address; - } diff --git a/addons/api/addon/models/fragment-host-attributes.js b/addons/api/addon/models/fragment-host-attributes.js new file mode 100644 index 000000000..114da4bca --- /dev/null +++ b/addons/api/addon/models/fragment-host-attributes.js @@ -0,0 +1,9 @@ +import Fragment from 'ember-data-model-fragments/fragment'; +import { attr } from '@ember-data/model'; + +export default class FragmentHostAttributesModel extends Fragment { + + @attr('string', { + description: 'The address (DNS or IP name) used to reach the host' + }) address; +} diff --git a/addons/api/addon/models/host.js b/addons/api/addon/models/host.js index 451097080..a2e855084 100644 --- a/addons/api/addon/models/host.js +++ b/addons/api/addon/models/host.js @@ -1,3 +1,12 @@ import GeneratedHostModel from '../generated/models/host'; +import { fragment } from 'ember-data-model-fragments/attributes'; -export default class HostModel extends GeneratedHostModel {} +export default class HostModel extends GeneratedHostModel { + + /** + * Attributes of this resource, if any, represented as a JSON fragment. + * @type {FragmentHostAttributesModel} + */ + @fragment('fragment-host-attributes', { defaultValue: {} }) attributes; + +} diff --git a/addons/api/app/models/fragment-host-attributes.js b/addons/api/app/models/fragment-host-attributes.js new file mode 100644 index 000000000..201efcb7a --- /dev/null +++ b/addons/api/app/models/fragment-host-attributes.js @@ -0,0 +1 @@ +export { default } from 'api/models/fragment-host-attributes'; diff --git a/addons/api/tests/unit/models/host-test.js b/addons/api/tests/unit/models/host-test.js index d19d98fc3..3cc0a3ad9 100644 --- a/addons/api/tests/unit/models/host-test.js +++ b/addons/api/tests/unit/models/host-test.js @@ -10,4 +10,15 @@ module('Unit | Model | host', function(hooks) { let model = store.createRecord('host', {}); assert.ok(model); }); + + test('it contains attributes', function(assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('host', { + type: 'static', + attributes: { + address: '127.0.0.1' + } + }); + assert.equal(model.attributes.address, '127.0.0.1'); + }); });