Class: Sqreen::Graft::Callback
- Inherits:
-
Object
- Object
- Sqreen::Graft::Callback
- Defined in:
- lib/sqreen/graft/callback.rb
Instance Attribute Summary collapse
-
#flow ⇒ Object
readonly
Returns the value of attribute flow.
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#mandatory ⇒ Object
readonly
Returns the value of attribute mandatory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object
- #disable ⇒ Object
- #disabled? ⇒ Boolean
- #enable ⇒ Object
-
#initialize(name = nil, opts = {}, &block) ⇒ Callback
constructor
A new instance of Callback.
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
#flow ⇒ Object (readonly)
Returns the value of attribute flow.
11 12 13 |
# File 'lib/sqreen/graft/callback.rb', line 11 def flow @flow end |
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
11 12 13 |
# File 'lib/sqreen/graft/callback.rb', line 11 def ignore @ignore end |
#mandatory ⇒ Object (readonly)
Returns the value of attribute mandatory.
11 12 13 |
# File 'lib/sqreen/graft/callback.rb', line 11 def mandatory @mandatory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/sqreen/graft/callback.rb', line 11 def name @name end |
#rank ⇒ Object (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 |
#disable ⇒ Object
29 30 31 |
# File 'lib/sqreen/graft/callback.rb', line 29 def disable @disabled = true end |
#disabled? ⇒ Boolean
37 38 39 |
# File 'lib/sqreen/graft/callback.rb', line 37 def disabled? @disabled end |
#enable ⇒ Object
33 34 35 |
# File 'lib/sqreen/graft/callback.rb', line 33 def enable @disabled = false end |