Sha256: 27dd88aab2c32f117990e7cbd896453f384e498ec38f7ed517a60eeb5f528bfb

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

module Creeper
  module Extensions
    class Proxy < BasicObject
      def initialize(performable, target, at=nil)
        @performable = performable
        @target = target
        @at = at
      end

      def method_missing(name, *args)
        # Creeper 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

3 entries across 3 versions & 1 rubygems

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