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

[FEATURE ds-transform-pass-options] pass options to DS.Transform #4086

Merged
merged 1 commit into from
Jan 27, 2016
Merged

[FEATURE ds-transform-pass-options] pass options to DS.Transform #4086

merged 1 commit into from
Jan 27, 2016

Commits on Jan 18, 2016

  1. [FEATURE ds-transform-pass-options] pass options to DS.Transform

    This feature passes the options hash defined for an attribute to the
    `serialize` and `deserialize` methods of `DS.Transform`:
    
    ```js
    // app/models/post.js
    export default Model.extend({
      text: DS.attr('text'),
    
      otherText: DS.attr('text', {
        lowercaseInput: true,
        uppercaseOutput: true
      })
    });
    
    // app/transforms/text.js
    export default DS.Tranform.extend({
      serialize(value, options) {
        if (options.uppercaseOutput) {
          return value.toUpperCase();
        }
    
        return value;
      },
    
      deserialize(value, options) {
        if (options.lowercaseInput) {
          return value.toLowerCase();
        }
    
        return value;
      }
    });
    ```
    pangratz committed Jan 18, 2016
    Configuration menu
    Copy the full SHA
    9ab5c5e View commit details
    Browse the repository at this point in the history