Created
December 1, 2014 16:28
-
-
Save blaix/4539747d2f888ed5a201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PropertyObserverExample | |
def number | |
@number ||= 0 | |
end | |
def number=(new_number) | |
old_number = @number | |
puts "About to change to #{new_number}" | |
@number = new_number | |
puts "Just changed from #{old_number} to #{new_number}!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment