1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/extensions/generic_proxy.rb
Mike Perham 2080412119 Client API update:
- Add API for configuring options per Worker class
- Removed the Client API issues preventing it working on Ruby 1.8
- Cleanups to various APIs for upcoming 1.0 release.
2012-04-01 19:53:45 -07:00

21 lines
671 B
Ruby

module Sidekiq
module Extensions
class Proxy < (RUBY_VERSION < '1.9' ? Object : BasicObject)
def initialize(performable, target)
@performable = performable
@target = target
end
def method_missing(name, *args)
# Sidekiq has a limitation in that its message must be JSON.
# JSON can't round trip real Ruby objects so we use YAML to
# serialize the objects to a String. The YAML will be converted
# to JSON and then deserialized on the other side back into a
# Ruby object.
obj = [@target, name, args]
@performable.perform_async(::YAML.dump(obj))
end
end
end
end