Module: Quebert::AsyncSender::Instance

Defined in:
lib/quebert/async_sender/instance.rb

Overview

Perform jobs on instances of classes

Defined Under Namespace

Modules: ClassMethods Classes: InstanceJob

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/quebert/async_sender/instance.rb', line 11

def self.included(base)
  # Its not as simple as including initialize in a class, we
  # have to do some tricks to make it work so we can put the include
  # before the initialize method as opposed to after. Ah, and thanks PivotalLabs for this.
  base.extend ClassMethods
  base.overwrite_initialize
  base.instance_eval do
    def method_added(name)
      return if name != :initialize
      overwrite_initialize
    end
  end
end

Instance Method Details

#async_send(meth, *args) ⇒ Object



46
47
48
# File 'lib/quebert/async_sender/instance.rb', line 46

def async_send(meth, *args)
  InstanceJob.new(self.class.name, @_init_args, meth, *args).enqueue
end

#initialize_with_async_sender(*args) ⇒ Object



25
26
27
# File 'lib/quebert/async_sender/instance.rb', line 25

def initialize_with_async_sender(*args)
  initialize_without_async_sender(*(@_init_args = args))
end