system/classes/Model.php
protected function _getAttributeDataWhenSet($attributeName, $query = false, $loadMap = false, $record = false) 
    {
      // Check if the stored data is numeric.
      // If it's not, then we don't need to worry about it being a
      // class reference that we need to fetch.
      if (is_numeric($this->model_data[$attributeName])) {

        // If the attribute is defined as a model relationship, then the number is 
        // a placeholder or ID and needs to be converted into a model.
        if ($this->_isRelation($attributeName) && !isset($this->model_dynamicOff)) {
          $this->$attributeName = $this->_getRelation($attributeName, $query, $loadMap, $record);
        }
      }

      $this->beforeGet($attributeName); // Lifecycle callback
      $returnValue = $this->model_data[$attributeName];
      $this->afterGet($attributeName, $returnValue); // Lifecycle callback
      return $returnValue;
    }
protected function _getAttributeDataWhenSet($attributeName, $query = false, $loadMap = false, $record = false) 
    {
      // Check if the stored data is numeric.
      // If it's not, then we don't need to worry about it being a
      // class reference that we need to fetch.
      if (is_numeric($this->model_data[$attributeName])) {

        // If the attribute is defined as a model relationship, then the number is 
        // a placeholder or ID and needs to be converted into a model.
        if ($this->_isRelation($attributeName) && !isset($this->model_dynamicOff)) {
          $this->$attributeName = $this->_getRelation($attributeName, $query, $loadMap, $record);
        }
      }

      $this->beforeGet($attributeName); // Lifecycle callback
      $returnValue = $this->model_data[$attributeName];
      $this->afterGet($attributeName, $returnValue); // Lifecycle callback
      return $returnValue;
    }
Returns the appropriate value for when a model attribute needs to be fetched and there is a
cooresponding value in the model_data array.

@requires $this->model_data[$attributeName] must be set.
@param $attributeName string The name of the attribute value to be retrieved.
@return mixed