// apply updates the action with information from a decision.
apply updates the action with information from a decision.
// apply updates the action with information from a decision .
func (a *Action) apply(e *Engine, d Decision) error {
	if d.error != nil {
		return d.error
	}
	if d.post != nil {
		a.post = d.post
	}
	if d.replacement != nil {
		if a.assignableTo == nil {
			return errors.New("this value cannot be replaced")
		}
		if a.typeData.TypeID != d.replacementType {
			if a.assignableTo.Kind == KindInterface {
				if a.assignableTo.IntfWrap(d.replacementType, d.replacement) == nil {
					return fmt.Errorf(
						"type %s is unknown or not assignable to %s",
						e.Stringify(d.replacementType), e.Stringify(a.assignableTo.TypeID))
				}
				a.typeData = e.typeData(d.replacementType)
			} else {
				return fmt.Errorf(
					"cannot change type of %s to %s",
					e.Stringify(a.assignableTo.TypeID), e.Stringify(d.replacementType))
			}
		}
		a.dirty = true
		a.replaced = true
		a.value = d.replacement
	}
	return nil
}
func ( a * Action ) apply ( e * Engine , d Decision ) error { if d . error != nil { return d . error } if d . post != nil { a . post = d . post } if d . replacement != nil { if a . assignableTo == nil { return errors . New ( " " ) } if a . typeData . TypeID != d . replacementType { if a . assignableTo . Kind == KindInterface { if a . assignableTo . IntfWrap ( d . replacementType , d . replacement ) == nil { return fmt . Errorf ( " " , e . Stringify ( d . replacementType ) , e . Stringify ( a . assignableTo . TypeID ) ) } a . typeData = e . typeData ( d . replacementType ) } else { return fmt . Errorf ( " " , e . Stringify ( a . assignableTo . TypeID ) , e . Stringify ( d . replacementType ) ) } } a . dirty = true a . replaced = true a . value = d . replacement } return nil }
apply updates the action with information from a decision.
apply updates the action with information from a decision .
// The user can only change the type of the object if it's being // assigned to an interface slot. Even then, we'll want to // check the assignability.