require 'observer' class User include Observable attr_accessor :username attr_accessor :password def initialize(username, password) @username = username @password = password end def change_username changed @username = "789" notify_observers end end class Foo def update puts "attribute has been updated" end end user = User.new("123", "456") user.add_observer(Foo.new) user.change_username?