Sha256: d6be4c734044a23a12f70c37012a4ceb58801fbe2085bb127ceb0c76ad6b0f1e

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

class Tennis::Worker::Deferable::Action
  def initialize(worker_class, receiver)
    @worker_class = worker_class
    @receiver = receiver
    _create_methods!
  end

  private

  def _create_methods!
    _methods.each do |method|
      self.define_singleton_method(method) do |*arguments|
        @worker_class.send_work([@receiver, method, arguments])
      end
    end
  end

  def _methods
    if @receiver.kind_of?(Class)
      @receiver.methods(false).map(&:to_s)
    else
      @receiver.class.instance_methods(false).map(&:to_s)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tennis-jobs-0.3.1 lib/tennis/worker/deferable/action.rb
tennis-jobs-0.3.0 lib/tennis/worker/deferable/action.rb