Skip to content

Instantly share code, notes, and snippets.

@steveh
Created July 10, 2017 03:43
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 steveh/5469108892874702a7e05cfd58e08750 to your computer and use it in GitHub Desktop.
Save steveh/5469108892874702a7e05cfd58e08750 to your computer and use it in GitHub Desktop.
# before
invoiced = Invoiced::Client.new("{API_KEY}")
# after
RateLimiter = Struct.new(:really) do
def method_missing(method, *args)
if can_do_the_thing?
really.public_send(method, *args)
else
raise CantDoTheThing
end
end
end
invoiced = RateLimiter.new(Invoiced::Client.new("{API_KEY}"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment