Skip to content

Instantly share code, notes, and snippets.

@blaix
Created December 1, 2014 16:28
Show Gist options
  • Save blaix/4539747d2f888ed5a201 to your computer and use it in GitHub Desktop.
Save blaix/4539747d2f888ed5a201 to your computer and use it in GitHub Desktop.
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