How do I alias a setter function?

I've got the following code that is only partly working:



Code:
alias_method :shaz_old_hp=, :hp=

def hp=(hp)
# do some extra stuff here
shaz_old_hp = hp
end
When this is called, the new function IS getting called, but the old one isn't. The extra stuff is being done, but hp on the actor isn't changing.

I've also tried calling it these ways:



Code:
shaz_old_hp=hp
shaz_old_hp= hp
shaz_old_hp=(hp)
and none of them are calling the original Game_Battler.hp= method.

Does anyone know what the correct way to call the aliased method is?

Edit: *sigh*

One final look at Google provided the answer immediately after I posted this. Why didn't I choose those particular keywords in the first place?

The answer is this:



Code:
self.shaz_old_hp = hp
I'm curious why your code didn't work.

Is it because ruby treated shaz_old_hp as a variable rather than a method call?
This is where I found my answer:

http://stackoverflow...methods-in-ruby

In particular

I don't think Ruby will recognize

​

old_name = whatever

as a method call when it lacks an object reference

​
It may well be doing what you say - treating it as a method variable.
Code:
alias :old_method :method=

def method=(n)
  # do some extra stuff here
  old_method(n)
end

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-alias-a-setter-function.3127/