Sha256: 05e4432c910e7aa7bacd140ab193bbfdc28b473d32e3ad8a56b5ee7582c2c5af

Contents?: true

Size: 950 Bytes

Versions: 16

Compression:

Stored size: 950 Bytes

Contents

# typed: false

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/graft'

module Sqreen
  module Graft
    class Callback
      attr_reader :name, :rank, :mandatory, :flow, :ignore

      def initialize(name = nil, opts = {}, &block)
        @name = name
        @rank = opts[:rank] || 0
        @mandatory = opts[:mandatory] || false
        @flow = opts[:flow] || false
        @ignore = opts[:ignore] || false
        @block = block
        @disabled = false
      end

      def call(*args, &block)
        Sqreen::Graft.logger.debug { "[#{Process.pid}] Callback #{@name} disabled:#{disabled?}" }
        return if @disabled
        @block.call(*args, &block)
      end

      def disable
        @disabled = true
      end

      def enable
        @disabled = false
      end

      def disabled?
        @disabled
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sqreen-1.19.4 lib/sqreen/graft/callback.rb
sqreen-1.21.0.beta2 lib/sqreen/graft/callback.rb
sqreen-1.21.0.beta1 lib/sqreen/graft/callback.rb
sqreen-1.20.1-java lib/sqreen/graft/callback.rb
sqreen-1.20.1 lib/sqreen/graft/callback.rb
sqreen-1.20.0-java lib/sqreen/graft/callback.rb
sqreen-1.20.0 lib/sqreen/graft/callback.rb
sqreen-1.19.3-java lib/sqreen/graft/callback.rb
sqreen-1.19.3 lib/sqreen/graft/callback.rb
sqreen-1.19.2-java lib/sqreen/graft/callback.rb
sqreen-1.19.2 lib/sqreen/graft/callback.rb
sqreen-1.19.1-java lib/sqreen/graft/callback.rb
sqreen-1.19.1 lib/sqreen/graft/callback.rb
sqreen-1.19.0-java lib/sqreen/graft/callback.rb
sqreen-1.19.0 lib/sqreen/graft/callback.rb
sqreen-1.19.0.beta1 lib/sqreen/graft/callback.rb