Class: Graft::Callback
- Inherits:
-
Object
- Object
- Graft::Callback
- Defined in:
- lib/graft/callback.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(*args, **kwargs, &block) ⇒ Object
- #disable ⇒ Object
- #enable ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(name = nil, opts = {}, &block) ⇒ Callback
constructor
NOTE: opts is not used in the current implementation.
Constructor Details
#initialize(name = nil, opts = {}, &block) ⇒ Callback
NOTE: opts is not used in the current implementation
8 9 10 11 12 13 |
# File 'lib/graft/callback.rb', line 8 def initialize(name = nil, opts = {}, &block) @name = name @opts = opts @block = block @enabled = true end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/graft/callback.rb', line 5 def name @name end |
Instance Method Details
#call(*args, **kwargs, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/graft/callback.rb', line 16 def call(*args, &block) return unless enabled? @block.call(*args, &block) end |
#disable ⇒ Object
29 30 31 |
# File 'lib/graft/callback.rb', line 29 def disable @enabled = false end |
#enable ⇒ Object
33 34 35 |
# File 'lib/graft/callback.rb', line 33 def enable @enabled = true end |
#enabled? ⇒ Boolean
37 38 39 |
# File 'lib/graft/callback.rb', line 37 def enabled? @enabled end |