Module: StandardProcedure::Async::Actor

Defined in:
lib/standard_procedure/async/actor.rb

Defined Under Namespace

Classes: Message

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/standard_procedure/async/actor.rb', line 11

def self.included base
  base.class_eval do
    def self.async name, &implementation
      name = name.to_sym
      implementation_name = :"_#{name}"

      define_method name do |*args, **params|
        _add_message_to_queue(implementation_name, *args, **params)
      end

      define_method implementation_name do |*args, **params|
        instance_exec(*args, **params, &implementation)
      rescue => ex
        ex
      end
    end
  end
end