API Docs for: 0.25.0
Show:

File: addon/transforms/fixstring.js

  1. import DS from 'ember-data';
  2.  
  3. import fixSpecialChars from '../utils/fix-special-char';
  4.  
  5. /**
  6. * @module ember-osf
  7. * @submodule transforms
  8. */
  9.  
  10. /**
  11. Custom string field transform that uses the `fix-special-char` utility function to clean up malformed text sent
  12. from the server. This allows string fields to be correctly and transparently used in templates without manually fixing
  13. these characters for display on each use.
  14.  
  15. This transform is used when `fixstring` is passed as the type parameter to the DS.attr function.
  16. ```app/models/score.js
  17. import DS from 'ember-data';
  18. export default DS.Model.extend({
  19. astring: DS.attr('fixstring'),
  20. });
  21. ```
  22. @class fixstring
  23. @extends DS.StringTransform
  24. @uses fix-special-char
  25. */
  26. export default DS.StringTransform.extend({
  27. deserialize(serialized) {
  28. return fixSpecialChars(this._super(serialized));
  29. }
  30. });
  31.