-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embed records which use the attrs setting
- Loading branch information
1 parent
0a86ca7
commit 84c6275
Showing
12 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Model from 'ember-data/model'; | ||
import { hasMany, belongsTo } from 'ember-data/relationships'; | ||
import { fragment } from 'model-fragments/attributes'; | ||
|
||
export default Model.extend({ | ||
name : fragment('name'), | ||
salary: belongsTo('salary'), | ||
reviews: hasMany('review') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
rating: DS.attr('number'), | ||
date: DS.attr('date') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import DS from 'ember-data'; | ||
import { array } from 'model-fragments/attributes'; | ||
|
||
export default DS.Model.extend({ | ||
income: DS.attr('number'), | ||
benefits: array('string') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin,{ | ||
attrs: { | ||
salary: { | ||
serialize: true, | ||
deserialize: 'records' | ||
}, | ||
reviews: { | ||
serialize: true, | ||
deserialize: 'records' | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import FactoryGuy from 'ember-data-factory-guy'; | ||
|
||
FactoryGuy.define('manager', { | ||
default: { | ||
name: FactoryGuy.belongsTo('name') | ||
}, | ||
traits: { | ||
default_name_setup: { | ||
name: {} | ||
}, | ||
with_salary: { | ||
salary: FactoryGuy.belongsTo('salary') | ||
}, | ||
with_reviews: { | ||
reviews: FactoryGuy.hasMany('review', 2) | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FactoryGuy from 'ember-data-factory-guy'; | ||
|
||
FactoryGuy.define('review', { | ||
default: { | ||
rating: FactoryGuy.generate((num)=> num), | ||
date: new Date('2015-05-01') | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FactoryGuy from 'ember-data-factory-guy'; | ||
|
||
FactoryGuy.define('salary', { | ||
default: { | ||
income: 90000, | ||
benefits: ['health', 'company car', 'dental'] | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters