Permalink
Browse files

feat(MetaData): Ensure same reference

  • Loading branch information...
RWOverdijk committed Oct 7, 2016
1 parent 7eb46d1 commit f64fdef36be9f9e62c39d6d7f7f21a9bbf99e60a
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/MetaData.ts
@@ -1,4 +1,5 @@
import {Homefront} from 'homefront';
import {ProxyInterface} from './EntityInterface';
export class MetaData {
/**
@@ -37,16 +38,16 @@ export class MetaData {
/**
* Get metadata for provided target (accepts instance).
*
* @param {{}} instance
* @param {ProxyInterface} instance
*
* @returns {Homefront}
*/
static forInstance(instance: Object): Homefront {
static forInstance(instance: ProxyInterface): Homefront {
if (typeof instance !== 'object') {
throw new Error("Can't get metadata, provided instance isn't of type Object.");
}
return MetaData.ensure(instance);
return MetaData.ensure(instance.isEntityProxy ? instance.getTarget() : instance);
}
/**

0 comments on commit f64fdef

Please sign in to comment.