Sha256: 497ede91dafc80394cfa2fc153cb54ef1f7de955af6fc0462124c1b41c7866b7

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

module Onfire
  class Event
    module Debugging
      def self.included(base)
        base.extend ClassMethods
      end
      
      module ClassMethods
        # Blocks added with #debug are executed on every node while traversing up.
        #
        #   Event.debug do |node, evt|
        #     puts "traversing #{node}"
        #   end
        def debug(&block)
          debug_blocks << block
        end
        
        def debug_blocks
          @debug_blocks ||= []
        end
      end
      
      def process_node(node)
        self.class.debug_blocks.each do |debugger|
          debugger.call(node, self, node.handlers_for_event(self))
        end
        
        super
      end
      
      # Currently unused.
      def call_handler(proc, node)
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onfire-0.2.0 lib/onfire/debugging.rb