Class: Crystal::Callbacks::BeforeCallback

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



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/crystal/support/callbacks.rb', line 64

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