Class: Sqreen::Graft::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/sqreen/graft/callback.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, opts = {}, &block) ⇒ Callback

Returns a new instance of Callback.



13
14
15
16
17
18
19
20
21
# File 'lib/sqreen/graft/callback.rb', line 13

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

Instance Attribute Details

#flowObject (readonly)

Returns the value of attribute flow.



11
12
13
# File 'lib/sqreen/graft/callback.rb', line 11

def flow
  @flow
end

#ignoreObject (readonly)

Returns the value of attribute ignore.



11
12
13
# File 'lib/sqreen/graft/callback.rb', line 11

def ignore
  @ignore
end

#mandatoryObject (readonly)

Returns the value of attribute mandatory.



11
12
13
# File 'lib/sqreen/graft/callback.rb', line 11

def mandatory
  @mandatory
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/sqreen/graft/callback.rb', line 11

def name
  @name
end

#rankObject (readonly)

Returns the value of attribute rank.



11
12
13
# File 'lib/sqreen/graft/callback.rb', line 11

def rank
  @rank
end

Instance Method Details

#call(*args, &block) ⇒ Object



23
24
25
26
27
# File 'lib/sqreen/graft/callback.rb', line 23

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

#disableObject



29
30
31
# File 'lib/sqreen/graft/callback.rb', line 29

def disable
  @disabled = true
end

#disabled?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/sqreen/graft/callback.rb', line 37

def disabled?
  @disabled
end

#enableObject



33
34
35
# File 'lib/sqreen/graft/callback.rb', line 33

def enable
  @disabled = false
end