class Blah attr_accessor :x def incr @x += 1 end end o = Blah.new o.x = 5 o.x # => 5 o.incr o.x # => 6