registerSetting (...settingOrSpec) {
    // resolve single arg (preventing infinite loop)
    if (settingOrSpec.length === 1) {
      settingOrSpec = settingOrSpec[0]
    }

    // handle multiple settings or specifications
    if (Array.isArray(settingOrSpec)) {
      settingOrSpec.forEach(settingOrSpec =>
        this.registerSetting(settingOrSpec))
      return this
    }

    // retrieve setting object
    const setting = (settingOrSpec instanceof Setting)
      ? settingOrSpec
      : SettingFactory.getInstance().create(settingOrSpec)

    // check if name already exists
    if (this.getSetting(setting.getName()) !== null) {
      throw new Error(
        `Setting with name '${setting.getName()}' has already ` +
        `been registered to Brick.`)
    }

    // register setting
    this._settings.push(setting)
    setting.setDelegate(this)

    // add setting as subview
    this.hasView() && this.getView().addSubview(setting.getView())

    return this
  }
/**
   * Registers a single or multiple Settings.
   * @example
   * // register number setting inside brick constructor
   * constructor () {
   *   super()
   *   this.registerSetting({
   *     name: 'a',
   *     type: 'number',
   *     value: 5,
   *     options: { integer: true, min: 1 }
   *   })
   * }
   * @protected
   * @param {...Setting|Object|Setting[]|Object[]} settingOrSpec
   * Single or array of Setting objects or Setting specifications described
   * at {@link SettingFactory.create}.
   * @throws Throws an error if specification is malformed.
   * @throws Throws an error if Setting type has not been registered.
   * @throws Throws an error if Setting with given name is already registered.
   * @return {Brick} Fluent interface
   */
Registers a single or multiple Settings.
Registers a single or multiple Settings .
registerSetting (...settingOrSpec) {
    if (settingOrSpec.length === 1) {
      settingOrSpec = settingOrSpec[0]
    }
    if (Array.isArray(settingOrSpec)) {
      settingOrSpec.forEach(settingOrSpec =>
        this.registerSetting(settingOrSpec))
      return this
    }
    const setting = (settingOrSpec instanceof Setting)
      ? settingOrSpec
      : SettingFactory.getInstance().create(settingOrSpec)
    if (this.getSetting(setting.getName()) !== null) {
      throw new Error(
        `Setting with name '${setting.getName()}' has already ` +
        `been registered to Brick.`)
    }
    this._settings.push(setting)
    setting.setDelegate(this)
    this.hasView() && this.getView().addSubview(setting.getView())
    return this
  }
registerSetting ( ... settingOrSpec ) { if ( settingOrSpec . length === 1 ) { settingOrSpec = settingOrSpec [ 0 ] } if ( Array . isArray ( settingOrSpec ) ) { settingOrSpec . forEach ( settingOrSpec => this . registerSetting ( settingOrSpec ) ) return this } const setting = ( settingOrSpec instanceof Setting ) ? settingOrSpec : SettingFactory . getInstance ( ) . create ( settingOrSpec ) if ( this . getSetting ( setting . getName ( ) ) !== null ) { throw new Error ( ` ${ setting . getName ( ) } ` + ` ` ) } this . _settings . push ( setting ) setting . setDelegate ( this ) this . hasView ( ) && this . getView ( ) . addSubview ( setting . getView ( ) ) return this }
Registers a single or multiple Settings.
Registers a single or multiple Settings .
// resolve single arg (preventing infinite loop) // handle multiple settings or specifications // retrieve setting object // check if name already exists // register setting // add setting as subview