Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(repository): Cast values if they have type decorators
  • Loading branch information
RWOverdijk committed Feb 23, 2016
1 parent c38020a commit a40d763
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/repository.js
@@ -1,5 +1,6 @@
import {inject} from 'aurelia-dependency-injection'; import {inject} from 'aurelia-dependency-injection';
import {Config} from 'spoonx/aurelia-api'; import {Config} from 'spoonx/aurelia-api';
import typer from 'typer';


@inject(Config) @inject(Config)
export class Repository { export class Repository {
Expand Down Expand Up @@ -164,6 +165,12 @@ export class Repository {


let value = data[key]; let value = data[key];


if (entityMetadata.has('types', key)) {
populatedData[key] = typer.cast(value, entityMetadata.fetch('types', key));

continue;
}

if (!entityMetadata.has('associations', key) || typeof value !== 'object') { if (!entityMetadata.has('associations', key) || typeof value !== 'object') {
// Not an association, or not an object. clean copy. // Not an association, or not an object. clean copy.
populatedData[key] = value; populatedData[key] = value;
Expand Down

0 comments on commit a40d763

Please sign in to comment.