Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion addon/-private/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { isDescriptor } from '../utils/utils';
const { keys } = Object;
const OPTION_KEYS = '__option_keys__';

const POSSIBLE_DECORATORS = ['AliasDecoratorImpl', 'ComputedDecoratorImpl'];

const OptionsObject = EmberObject.extend({
toObject() {
return this[OPTION_KEYS].reduce((obj, key) => {
Expand All @@ -17,9 +19,15 @@ export default class Options {
constructor({ model, attribute, options = {} }) {
const optionKeys = keys(options);
const createParams = { [OPTION_KEYS]: optionKeys, model, attribute };
const someOptionsAreCPs = optionKeys.some((key) => {
return (
isDescriptor(options[key]) ||
POSSIBLE_DECORATORS.includes(options[key]?.constructor?.name)
);
});

// If any of the options is a CP, we need to create a custom class for it
if (optionKeys.some((key) => isDescriptor(options[key]))) {
if (someOptionsAreCPs) {
return OptionsObject.extend(options).create(createParams);
}

Expand Down