* Wraps the entity in a `Reference` wrapper if the property is defined as `ref`.
(
entity: T | Reference<T>,
prop: EntityProperty<O, T>,
)
| 111 | * Wraps the entity in a `Reference` wrapper if the property is defined as `ref`. |
| 112 | */ |
| 113 | static wrapReference<T extends object, O extends object>( |
| 114 | entity: T | Reference<T>, |
| 115 | prop: EntityProperty<O, T>, |
| 116 | ): Reference<T> | T { |
| 117 | if (entity && prop.ref && !Reference.isReference(entity)) { |
| 118 | const ref = Reference.create(entity) as Reference<T>; |
| 119 | ref.property = prop; |
| 120 | |
| 121 | return ref; |
| 122 | } |
| 123 | |
| 124 | return entity; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Returns wrapped entity. |
no test coverage detected