module LinkedRails::Enhanceable

Public Instance Methods

enhanceable(klass_method, enhanceable) click to toggle source
Calls superclass method
# File lib/linked_rails/enhanceable.rb, line 12
def enhanceable(klass_method, enhanceable)
  include_enhancements(klass_method, enhanceable)

  define_singleton_method('inherited') do |target|
    super(target)
    target.include_enhancements(klass_method, enhanceable) if target.name
  end
end
include_enhancements(klass_method, enhanceable) click to toggle source
# File lib/linked_rails/enhanceable.rb, line 5
def include_enhancements(klass_method, enhanceable)
  try(klass_method)
    .try(:enhancement_modules, enhanceable)
    &.reject { |mod| include? mod }
    &.each { |mod| include mod }
end