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.rc.19 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.18 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.17 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.16 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.15 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.14 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.12 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.11 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.10 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.9 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.8 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.7 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.6 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.5 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.4 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.3 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.2 lib/graphiti/util/hooks.rb
graphiti-1.0.rc.1 lib/graphiti/util/hooks.rb
graphiti-1.0.beta.23 lib/graphiti/util/hooks.rb
graphiti-1.0.beta.22 lib/graphiti/util/hooks.rb