import { CONSTANTS } from '../interface/exported';

/**
 * @bindable
 * helps get values in attibutes
 *
 */
export function computedFrom(...options: any[]) {

    // get passed in options //todo, create interface
    let _options: any;
    _options = options;

    return function (target: any, key: any) {

        if (!target[CONSTANTS.META_COMPUTEDFROM]) {
            target[CONSTANTS.META_COMPUTEDFROM] = {};
        }



        // check if key is added, if not add
        if (!target[CONSTANTS.META_COMPUTEDFROM][key]) {
            target[CONSTANTS.META_COMPUTEDFROM][key] = {
                key: key,
                attributes: _options || {
                    attributes: []
                }
            };
        }

    };
}
