Module: ViewComponent::PolymorphicSlots

Included in:
Base
Defined in:
lib/view_component/polymorphic_slots.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

In older rails versions, using a concern isn’t a good idea here because they appear to not work with Module#prepend and class methods.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/view_component/polymorphic_slots.rb', line 7

def self.included(base)
  if base != ViewComponent::Base
    # :nocov:
    location = Kernel.caller_locations(1, 1)[0]

    warn(
      "warning: ViewComponent::PolymorphicSlots is now included in ViewComponent::Base by default "\
      "and can be removed from #{location.path}:#{location.lineno}"
    )
    # :nocov:
  end

  base.singleton_class.prepend(ClassMethods)
  base.include(InstanceMethods)
end