Sha256: b01ea4a3189328371d5696f9504a2977a3ced8a9f432539290a53ba49de3d187

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 Bytes

Contents

module Sidekiq
  module Extensions
    class Proxy < (RUBY_VERSION < '1.9' ? Object : BasicObject)
      def initialize(performable, target, at=nil)
        @performable = performable
        @target = target
        @at = at
      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]
        if @at
          @performable.perform_at(@at, ::YAML.dump(obj))
        else
          @performable.perform_async(::YAML.dump(obj))
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidekiq-2.0.3 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-2.0.2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-2.0.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-2.0.0 lib/sidekiq/extensions/generic_proxy.rb