diff --git a/addon/-private/options.js b/addon/-private/options.js index dfa9a77c..d517ddb6 100644 --- a/addon/-private/options.js +++ b/addon/-private/options.js @@ -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) => { @@ -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); }