Created
July 10, 2017 03:43
-
-
Save steveh/5469108892874702a7e05cfd58e08750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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