Created
August 5, 2021 10:01
-
-
Save krtschmr/154cea4f94b30d1dc4d08dc5e626ccd8 to your computer and use it in GitHub Desktop.
swag
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
class Testy | |
def easy | |
puts "hi" | |
end | |
def hash(a:, b:, c:) | |
puts a | |
puts b | |
puts c | |
end | |
def hard(s, a:, b:, c:) | |
puts s | |
puts a | |
puts b | |
puts c | |
end | |
end | |
class Worker | |
def self.perform_async(method, args, kwargs) | |
puts "in worker: " | |
puts "args: #{args.inspect}" | |
puts "kwargs: #{kwargs.inspect}" | |
if args.empty? | |
if kwargs.empty? | |
Testy.new.send(method) | |
else | |
Testy.new.send(method, kwargs) | |
end | |
else | |
Testy.new.send(method, *args, **kwargs) | |
end | |
end | |
end | |
def async(method, *args, **kwargs) | |
puts "in async:" | |
puts "args: #{args.inspect}" | |
puts "kwargs: #{kwargs.inspect}" | |
Worker.perform_async(method, args, kwargs) | |
end | |
puts "easy" | |
async(:easy) | |
puts "----" | |
puts "hash" | |
async(:hash, a: 1, b: 2, c: 3) | |
puts "----" | |
puts "hard" | |
async(:hard, "test", a: 1, b: 2, c: 3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment