Sha256: 6b8c38ef1ccfb1164b0026df759e1cdf67a89644490bfc4b56387ab0dacf6f9c
Contents?: true
Size: 639 Bytes
Versions: 62
Compression:
Stored size: 639 Bytes
Contents
module Graphiti module Util class Hooks def self.record self.hooks = [] begin yield.tap { run } ensure self.hooks = [] end end def self._hooks Thread.current[:_graphiti_hooks] ||= [] end private_class_method :_hooks def self.hooks=(val) Thread.current[:_graphiti_hooks] = val end # Because hooks will be added from the outer edges of # the graph, working inwards def self.add(prc) _hooks.unshift(prc) end def self.run _hooks.each { |h| h.call } end end end end
Version data entries
62 entries across 62 versions & 1 rubygems