Sha256: 703473ed4a760bcab70338e52acfcde10384bd7066c6ab51222fd95414eabab9
Contents?: true
Size: 652 Bytes
Versions: 13
Compression:
Stored size: 652 Bytes
Contents
module JsonapiCompliable module Util class Hooks def self.record self.hooks = [] begin yield.tap { run } ensure self.hooks = [] end end def self._hooks Thread.current[:_compliable_hooks] ||= [] end private_class_method :_hooks def self.hooks=(val) Thread.current[:_compliable_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
13 entries across 13 versions & 1 rubygems