Sha256: 8c8bd09a7d7336a13b672ee30331f9d78822563d6fc07a81f5410200ae19b9b5

Contents?: true

Size: 549 Bytes

Versions: 6

Compression:

Stored size: 549 Bytes

Contents

# frozen_string_literal: true

module ViewComponent::UseHelpers
  extend ActiveSupport::Concern

  class_methods do
    def use_helpers(*args)
      args.each do |helper_method|
        class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
          def #{helper_method}(*args, &block)
            raise HelpersCalledBeforeRenderError if view_context.nil?
            __vc_original_view_context.#{helper_method}(*args, &block)
          end
        RUBY

        ruby2_keywords(helper_method) if respond_to?(:ruby2_keywords, true)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
view_component-3.12.1 lib/view_component/use_helpers.rb
view_component-3.12.0 lib/view_component/use_helpers.rb
view_component-3.11.0 lib/view_component/use_helpers.rb
view_component-3.10.0 lib/view_component/use_helpers.rb
view_component-3.9.0 lib/view_component/use_helpers.rb
view_component-3.8.0 lib/view_component/use_helpers.rb