How to use the ember-metal.get function in ember-metal

To help you get started, we’ve selected a few ember-metal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember.js / packages / ember-runtime / lib / mixins / target_action_support.js View on Github external
function getTarget(instance) {
  // TODO: Deprecate specifying `targetObject`
  let target = get(instance, 'targetObject');

  // if a `targetObject` CP was provided, use it
  if (target) { return target; }

  // if _targetObject use it
  if (instance._targetObject) { return instance._targetObject; }

  target = get(instance, 'target');
  if (target) {
    if (typeof target === 'string') {
      let value = get(instance, target);
      if (value === undefined) {
        value = get(context.lookup, target);
      }

      return value;
    } else {
      return target;
    }
  }

  return null;
}
github emberjs / ember.js / packages / ember-runtime / lib / mixins / array.js View on Github external
replace(idx, amt, objects) {
    assert('The third argument to replace needs to be an array.', objects === null || objects === undefined || Array.isArray(objects));

    // if we replaced exactly the same number of items, then pass only the
    // replaced range. Otherwise, pass the full remaining array length
    // since everything has shifted
    let len = objects ? get(objects, 'length') : 0;
    arrayContentWillChange(this, idx, amt, len);

    if (len === 0) {
      this.splice(idx, amt);
    } else {
      replace(this, idx, amt, objects);
    }

    arrayContentDidChange(this, idx, amt, len);
    return this;
  },
github emberjs / ember.js / packages / ember-runtime / lib / mixins / mutable_array.js View on Github external
export function removeAt(array, start, len) {
  if ('number' === typeof start) {
    if ((start < 0) || (start >= get(array, 'length'))) {
      throw new EmberError(OUT_OF_RANGE_EXCEPTION);
    }

    // fast case
    if (len === undefined) {
      len = 1;
    }

    array.replace(start, len, EMPTY);
  }

  return array;
}
github emberjs / ember.js / packages / ember-application / lib / system / resolver.js View on Github external
knownForType(type) {
    let namespace = get(this, 'namespace');
    let suffix = StringUtils.classify(type);
    let typeRegexp = new RegExp(`${suffix}$`);

    let known = dictionary(null);
    let knownKeys = Object.keys(namespace);
    for (let index = 0; index < knownKeys.length; index++) {
      let name = knownKeys[index];

      if (typeRegexp.test(name)) {
        let containerName = this.translateToContainerFullname(type, name);

        known[containerName] = true;
      }
    }

    return known;
github emberjs / ember.js / packages / ember-glimmer / lib / syntax / curly-component.js View on Github external
templateFor(component, env) {
    let Template = get(component, 'layout');
    let owner = component[OWNER];
    if (Template) {
      return env.getTemplate(Template, owner);
    }
    let layoutName = get(component, 'layoutName');
    if (layoutName) {
      let template = owner.lookup('template:' + layoutName);
      if (template) {
        return template;
      }
    }
    return owner.lookup(DEFAULT_LAYOUT);
  }
github emberjs / ember.js / packages / ember-runtime / lib / mixins / target_action_support.js View on Github external
triggerAction(opts = {}) {
    let { action, target, actionContext } = opts;
    action = action || get(this, 'action');
    target = target || getTarget(this);

    if (actionContext === undefined) {
      actionContext = get(this, 'actionContextObject') || this;
    }

    if (target && action) {
      let ret;

      if (target.send) {
        ret = target.send(...[action].concat(actionContext));
      } else {
        assert(`The action '${action}' did not exist on ${target}`, typeof target[action] === 'function');
        ret = target[action](...[].concat(actionContext));
      }

      if (ret !== false) {
        return true;
      }
    }
github emberjs / ember.js / packages / ember-runtime / lib / mixins / array.js View on Github external
lastObject: computed(function() {
    return objectAt(this, get(this, 'length') - 1);
  }).readOnly(),
github emberjs / ember.js / packages / ember-runtime / lib / mixins / mutable_array.js View on Github external
pushObject(obj) {
    this.insertAt(get(this, 'length'), obj);
    return obj;
  },
github emberjs / ember.js / packages / ember-runtime / lib / mixins / array.js View on Github external
lastIndexOf(object, startAt) {
    let len = get(this, 'length');

    if (startAt === undefined || startAt >= len) {
      startAt = len - 1;
    }

    if (startAt < 0) {
      startAt += len;
    }

    for (let idx = startAt; idx >= 0; idx--) {
      if (objectAt(this, idx) === object) {
        return idx;
      }
    }

    return -1;
github emberjs / ember.js / packages / ember-routing / lib / services / routing.js View on Github external
hasRoute(routeName) {
    return get(this, 'router').hasRoute(routeName);
  },