class Fibril::TickProxy
Attributes
guard_names[RW]
target[RW]
tick_after[RW]
tick_before[RW]
Public Class Methods
new(target, *guard_names, tick_before: true, tick_after: false)
click to toggle source
# File lib/fibril/tick_proxy.rb, line 4 def initialize(target, *guard_names, tick_before: true, tick_after: false) self.target = target self.guard_names = guard_names self.tick_before, self.tick_after = tick_before, tick_after end
Public Instance Methods
method_missing(name, *args, &block)
click to toggle source
Execute target method within a new fibril
# File lib/fibril/tick_proxy.rb, line 13 def method_missing(name, *args, &block) context = target decorated = ->(*args){ Fibril.current.tick if tick_before result = block[*args] Fibril.current.tick if tick_after result } fibril{ context.send(name, *args, &decorated) }.tap do |guard| guard_names.each do |name| Fibril.guard.send("#{name}=", guard) end end end