Skip to content

Instantly share code, notes, and snippets.

@krtschmr
Created August 5, 2021 10:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
swag
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