Skip to content

Instantly share code, notes, and snippets.

@arwagner
Created September 23, 2012 00:30
Show Gist options
  • Save arwagner/3768353 to your computer and use it in GitHub Desktop.
Save arwagner/3768353 to your computer and use it in GitHub Desktop.
observer
require 'observer'
class Target
include Observable
end
class Watcher
def initialize target
target.add_observer self
end
def update *args
puts args.inspect
end
end
target = Target.new
watcher = Watcher.new(target)
target.notify_observers "foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment