Class: Vigilem::Core::Hooks::MetaCallback

Inherits:
CallbackProc
  • Object
show all
Defined in:
lib/vigilem/core/hooks/meta_callback.rb

Overview

TODO:

better name?

CallbackProc that remebers if it has been ran/evaluated/called

Instance Attribute Summary

Attributes included from Callback

#options, #result

Instance Method Summary collapse

Methods inherited from CallbackProc

#options

Methods included from Callback

#binding, new, #to_proc

Constructor Details

#initialize(cbp = nil, &block) ⇒ MetaCallback

Returns a new instance of MetaCallback.

Parameters:

  • cbp (CallbackProc) (defaults to: nil)

    a CallbackProc to be converted to a MetaCallback

  • block (Proc)

    a Proc to be converted to a MetaCallback



12
13
14
15
# File 'lib/vigilem/core/hooks/meta_callback.rb', line 12

def initialize(cbp=nil, &block)
  self.ran = false
  super(cbp || CallbackProc.new(&block))
end

Instance Method Details

#call(*args, &block) ⇒ Object

Returns the result of the proc.

Parameters:

  • args (Array)

    arguments to be passed to the proc

  • block (Proc)

    Proc to be passed to the proc

Returns:

  • the result of the proc



33
34
35
36
# File 'lib/vigilem/core/hooks/meta_callback.rb', line 33

def call(*args, &block)
  self.ran = true
  super(*args, &block)
end

#evaluate(context, *args, &block) ⇒ Object Also known as: []

Returns the result of the.

Parameters:

  • context

    the context which to evaluate under

  • args (Array)

    arguments to be passed to the proc

  • block (Proc)

    Proc to be passed to the proc

Returns:

  • the result of the



22
23
24
25
# File 'lib/vigilem/core/hooks/meta_callback.rb', line 22

def evaluate(context, *args, &block)
  self.ran = true
  super(context, *args, &block)
end

#ran?TrueClass || FalseClass

whether or not this proc ran

Returns:

  • (TrueClass || FalseClass)


40
41
42
# File 'lib/vigilem/core/hooks/meta_callback.rb', line 40

def ran?
  @ran
end