Skip to content

Commit

Permalink
chore: uses isComputed and isDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixelik committed Sep 18, 2023
1 parent f60c104 commit ed1d62f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions addon/-private/options.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import EmberObject, { get } from '@ember/object';
import { isDescriptor } from '../utils/utils';
import EmberObject, { get } from '@ember/object';
import { isComputed } from '@ember/-internals/metal';

const { keys } = Object;
const OPTION_KEYS = '__option_keys__';

const POSSIBLE_DECORATORS = [
'AliasDecoratorImpl'
]

const OptionsObject = EmberObject.extend({
toObject() {
return this[OPTION_KEYS].reduce((obj, key) => {
Expand All @@ -22,9 +19,9 @@ export default class 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)
return isComputed(options, key) || isDescriptor(options[key]);
});

// If any of the options is a CP, we need to create a custom class for it
if (someOptionsAreCPs) {
return OptionsObject.extend(options).create(createParams);
Expand Down

0 comments on commit ed1d62f

Please sign in to comment.