Module: ViewComponent::CaptureCompatibility::InstanceMethods

Defined in:
lib/view_component/capture_compatibility.rb

Instance Method Summary collapse

Instance Method Details

#capture(*args, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/view_component/capture_compatibility.rb', line 30

def capture(*args, &block)
  # Handle blocks that originate from C code and raise, such as `&:method`
  return original_capture(*args, &block) if block.source_location.nil?

  block_context = block.binding.receiver

  if block_context != self && block_context.class < ActionView::Base
    block_context.original_capture(*args, &block)
  else
    original_capture(*args, &block)
  end
end