2018-10-19 15:17:02 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
2018-11-02 14:44:36 +00:00
|
|
|
const _isLegacy = function(token) {
|
2018-11-06 18:08:10 +00:00
|
|
|
// Empty Rules take priority over a Legacy: true
|
|
|
|
// in order to make this decision
|
2018-11-02 14:44:36 +00:00
|
|
|
const rules = get(token, 'Rules');
|
2018-11-06 18:08:10 +00:00
|
|
|
if (rules != null) {
|
|
|
|
return rules.trim() !== '';
|
|
|
|
}
|
|
|
|
const legacy = get(token, 'Legacy');
|
|
|
|
if (typeof legacy !== 'undefined') {
|
|
|
|
return legacy;
|
|
|
|
}
|
|
|
|
return false;
|
2018-11-02 14:44:36 +00:00
|
|
|
};
|
2018-10-19 15:17:02 +00:00
|
|
|
export function isLegacy(params, hash) {
|
|
|
|
const token = params[0];
|
2018-11-02 14:44:36 +00:00
|
|
|
// is array like (RecordManager isn't an array)
|
|
|
|
if (typeof token.length !== 'undefined') {
|
|
|
|
return token.find(function(item) {
|
|
|
|
return _isLegacy(item);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return _isLegacy(token);
|
2018-10-19 15:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default helper(isLegacy);
|