public
Created

Is this the best pattern for deprecating a method paramater?

  • Download Gist
deprecated.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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

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

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.