class JsonapiCompliable::Util::Hooks

Public Class Methods

add(prc) click to toggle source

Because hooks will be added from the outer edges of the graph, working inwards

# File lib/jsonapi_compliable/util/hooks.rb, line 24
def self.add(prc)
  _hooks.unshift(prc)
end
hooks=(val) click to toggle source
# File lib/jsonapi_compliable/util/hooks.rb, line 18
def self.hooks=(val)
  Thread.current[:_compliable_hooks] = val
end
record() { || ... } click to toggle source
# File lib/jsonapi_compliable/util/hooks.rb, line 4
def self.record
  self.hooks = []
  begin
    yield.tap { run }
  ensure
    self.hooks = []
  end
end
run() click to toggle source
# File lib/jsonapi_compliable/util/hooks.rb, line 28
def self.run
  _hooks.each { |h| h.call }
end

Private Class Methods

_hooks() click to toggle source
# File lib/jsonapi_compliable/util/hooks.rb, line 13
def self._hooks
  Thread.current[:_compliable_hooks] ||= []
end