Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amiel
Created June 13, 2013 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiel/5777288 to your computer and use it in GitHub Desktop.
Save amiel/5777288 to your computer and use it in GitHub Desktop.
Discover what methods in a class are actually being used. Either use dependency injection or completely replace your object with this one.
class WhatIsMyPublicApi < BasicObject
def initialize(*arguments)
method_missing('initialize', *arguments)
end
def method_missing(method, *arguments)
::File.open('what_is_my_public_api.log', 'a') do |f|
args = arguments.inspect.gsub(/^\[|\]$/, '')
f.write("#{method}(#{args})\n")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment