Sha256: b41e11c638a4432034671823787a2adf32c7863c08644fb88455eaafefe499ee

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

module Sidekiq
  module Extensions
    class Proxy < ::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]
        ::Sidekiq::Client.push('class' => @performable.name, 'args' => [::YAML.dump(obj)])
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-0.8.0 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-0.7.0 lib/sidekiq/extensions/generic_proxy.rb