Skip to content

Instantly share code, notes, and snippets.

@scottwater
Created April 5, 2012 20:29
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 scottwater/2313845 to your computer and use it in GitHub Desktop.
Save scottwater/2313845 to your computer and use it in GitHub Desktop.
Is this the best pattern for deprecating a method paramater?
module FullContact
class Client
module Person
# Returns extended information for a given person (email, phone, twitter or facebook)
#
def person(options={})
if options.is_a?(String)
warn "[DEPRECATION] supplying an email address directly is deprecated. Please use {email: #{options}} instead."
options = {:email => options}
end
response = get('person', options)
format.to_s.downcase == 'xml' ? response['person'] : response
end
end
end
end
@scottwater
Copy link
Author

I should have pointed out the method initially looked like this:

def person(email)
response = get('person', email: email)
#....
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment