module RubyFeatures::Lazy

Constants

ACTIVE_SUPPORT_LAZY_TARGETS

Public Class Methods

apply(target) { || ... } click to toggle source
# File lib/ruby-features/lazy.rb, line 11
def apply(target, &block)
  if RubyFeatures.active_support_available?
    target_namespace = RubyFeatures::Utils.underscore(target.split('::').first).to_sym

    if ACTIVE_SUPPORT_LAZY_TARGETS.include?(target_namespace)
      return ActiveSupport.on_load target_namespace, yield: true, &block
    end
  end

  yield
end