Skip to content

Instantly share code, notes, and snippets.

@krtschmr
Created August 5, 2021 10:01
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 krtschmr/154cea4f94b30d1dc4d08dc5e626ccd8 to your computer and use it in GitHub Desktop.
Save krtschmr/154cea4f94b30d1dc4d08dc5e626ccd8 to your computer and use it in GitHub Desktop.
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