-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace property metadata instead of pushing a new one * Filter out duplicate property metadata * Add test for checking metadata of child classes
- Loading branch information
Showing
11 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
projects/ngx-hal/src/lib/helpers/update-property-metadata/update-property-metadata.helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ModelProperty } from '../../interfaces/model-property.interface'; | ||
|
||
// Modifies the original array | ||
export function updatePropertyMetadata<T extends ModelProperty>( | ||
modelProperties: Array<T>, | ||
newModelProperty: T, | ||
): Array<T> { | ||
const existingProperty: T = modelProperties.find((property: T) => { | ||
return property.name === newModelProperty.name; | ||
}); | ||
|
||
if (existingProperty) { | ||
const indexOfExistingProperty: number = modelProperties.indexOf(existingProperty); | ||
modelProperties[indexOfExistingProperty] = newModelProperty; | ||
} else { | ||
modelProperties.push(newModelProperty); | ||
} | ||
|
||
return modelProperties; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ModelConfig } from '../decorators/model-config.decorator'; | ||
import { MockModel2 } from './mock-model-2'; | ||
|
||
@ModelConfig({ | ||
type: 'MockChild2', | ||
endpoint: 'MockChild2', | ||
}) | ||
export class MockChildModel2 extends MockModel2 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Attribute } from '../decorators/attribute.decorator'; | ||
import { HasOne } from '../decorators/has-one.decorator'; | ||
import { ModelConfig } from '../decorators/model-config.decorator'; | ||
import { MockChildModel2 } from './mock-child-model-2'; | ||
import { MockModel } from './mock-model'; | ||
|
||
@ModelConfig({ | ||
type: 'MockChild', | ||
endpoint: 'mock-child-model-endpoint', | ||
}) | ||
export class MockChildModel extends MockModel { | ||
@Attribute() | ||
name: string; | ||
|
||
@HasOne({ | ||
propertyClass: MockChildModel2, | ||
}) | ||
mockModel2Connection: MockChildModel2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters