def apply_operation(operation, client_version)
      Rails.logger.debug "Applying client version #{client_version}, server version: #{version}"

      unless client_version > version
        operation = transform_old_operation(operation, client_version)
      end

      store_operation(operation)

      self.value = new_text(operation)

      [version, operation]
    end
def apply_operation(operation, client_version)
      Rails.logger.debug "Applying client version #{client_version}, server version: #{version}"

      unless client_version > version
        operation = transform_old_operation(operation, client_version)
      end

      store_operation(operation)

      self.value = new_text(operation)

      [version, operation]
    end
Based on https://github.com/Operational-Transformation/ot.js/blob/15d4e7/lib/server.js#L16