Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Cleanup example code in attr #4798

Merged
merged 1 commit into from
Feb 13, 2017
Merged
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
12 changes: 9 additions & 3 deletions addon/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ function getValue(record, key) {
export default DS.Model.extend({
username: attr('string'),
email: attr('string'),
settings: attr({defaultValue: function() {
return {};
}})
settings: attr({
defaultValue() {
return {};
}
})
});
```

Expand All @@ -83,6 +85,8 @@ function getValue(record, key) {
transformation and adapt the corresponding value, based on the config:

```app/models/post.js
import DS from 'ember-data';

export default DS.Model.extend({
text: DS.attr('text', {
uppercase: true
Expand All @@ -91,6 +95,8 @@ function getValue(record, key) {
```

```app/transforms/text.js
import DS from 'ember-data';

export default DS.Transform.extend({
serialize(value, options) {
if (options.uppercase) {
Expand Down