Sha256: 53970c0d610c5f9e61d7475a0d5a3192daf64d1793d3b033369ec808ca3bda71

Contents?: true

Size: 553 Bytes

Versions: 2

Compression:

Stored size: 553 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.execute([@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.2.0 lib/tennis/worker/deferable/action.rb
tennis-jobs-0.1.0 lib/tennis/worker/deferable/action.rb