Class: Crystal::Callbacks::AfterCallback

Inherits:
AbstractCallback show all
Defined in:
lib/crystal/support/callbacks.rb

Instance Attribute Summary

Attributes inherited from AbstractCallback

#conditions, #executor, #terminator

Instance Method Summary collapse

Methods inherited from AbstractCallback

#add_to_chain, #run?, #terminate?

Instance Method Details

#build_block(target, &the_next) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/crystal/support/callbacks.rb', line 94

def build_block target, &the_next
  lambda do
    result = if executor.string_or_symbol?
      target.send executor
    elsif executor.is_a? Proc
      executor.call target
    else
      must_be.never_called
    end
  
    the_next.call unless terminate? target, result
  end      
end