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

Version Path
graphiti-1.0.alpha.26 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.25 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.24 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.23 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.22 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.21 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.20 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.19 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.18 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.17 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.16 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.15 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.14 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.12 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.11 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.10 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.9 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.8 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.7 lib/graphiti/util/hooks.rb
graphiti-1.0.alpha.6 lib/graphiti/util/hooks.rb