From: Brian Candler Date: 2011-10-21T00:22:43+09:00 Subject: Re: Call method on attribute update Jason Lillywhite wrote in post #1027518: > Hello, > > I have an attribute in my class called @yn. If I change the value of @yn > by doing this: > > foo.yn = 100.0 > > How do I cause another method in the class to automatically run? class Foo attr_accessor :yn # This is the general way to wrap a method call alias :old_yn= :yn= def yn=(val) self.old_yn = val puts "Yay!" end end foo = Foo.new foo.yn = 123 -- Posted via http://www.ruby-forum.com/.