Module: T::Private::Mixins

Defined in:
lib/types/private/mixins/mixins.rb

Class Method Summary collapse

Class Method Details

.declare_mixes_in_class_methods(mixin, class_methods) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/types/private/mixins/mixins.rb', line 14

def self.declare_mixes_in_class_methods(mixin, class_methods)
  if mixin.is_a?(Class)
    raise "Classes cannot be used as mixins, and so mixes_in_class_methods cannot be used on a Class."
  end

  if Abstract::Data.key?(mixin, :class_methods_mixin)
    raise "mixes_in_class_methods can only be used once per module."
  end

  mixin.singleton_class.include(MixesInClassMethods)
  Abstract::Data.set(mixin, :class_methods_mixin, class_methods)
end