Skip to content

Instantly share code, notes, and snippets.

@Dispader
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save Dispader/e27e7f497414e15ad5fb to your computer and use it in GitHub Desktop.

Select an option

Save Dispader/e27e7f497414e15ad5fb to your computer and use it in GitHub Desktop.
final
class Proxy
attr_reader :messages
def initialize(target_object)
@object = target_object
@messages = []
end
def called?(name)
@messages.include?(name)
end
def number_of_times_called(name)
@messages.count(name)
end
def method_missing(name, *args, &block)
@messages << name
@object.send(name, *args, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment