Class: Plumbing::Actor::Inline

Inherits:
Object
  • Object
show all
Defined in:
lib/plumbing/actor/inline.rb

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Inline

Returns a new instance of Inline.



4
5
6
# File 'lib/plumbing/actor/inline.rb', line 4

def initialize target
  @target = target
end

Instance Method Details

#in_context?Boolean

Returns:

  • (Boolean)


26
# File 'lib/plumbing/actor/inline.rb', line 26

def in_context? = true

#safelyObject



20
21
22
23
24
# File 'lib/plumbing/actor/inline.rb', line 20

def safely(&)
  Plumbing.config.logger.debug { "-> #{@target.class}#perform_safely" }
  send_message(:perform_safely, &)
  nil
end

#send_message(message_name, *args, **params) ⇒ Object

Send the message to the target and wrap the result



9
10
11
12
13
14
15
16
17
18
# File 'lib/plumbing/actor/inline.rb', line 9

def send_message(message_name, *args, **params, &)
  Plumbing.config.logger.debug { "-> #{@target.class}##{message_name}(#{args.inspect}, #{params.inspect})" }
  Plumbing.config.logger.debug { "---> #{@target.class}##{message_name}(#{args.inspect}, #{params.inspect})" }
  value = @target.send(message_name, *args, **params, &)
  Plumbing.config.logger.debug { "===> #{@target.class}##{message_name} => #{value}" }
  Result.new(value)
rescue => ex
  Plumbing.config.logger.debug { "!!!! #{@target.class}##{message_name} => #{ex}" }
  Result.new(ex)
end

#stopObject



28
# File 'lib/plumbing/actor/inline.rb', line 28

def stop = nil