mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
5894d6805e
Kaminari can now coexist with other gems that defines `inherited`
22 lines
737 B
Ruby
22 lines
737 B
Ruby
require 'kaminari/models/active_record_model_extension'
|
|
|
|
module Kaminari
|
|
module ActiveRecordExtension
|
|
extend ActiveSupport::Concern
|
|
included do
|
|
# Future subclasses will pick up the model extension
|
|
class << self
|
|
def inherited_with_kaminari(kls) #:nodoc:
|
|
inherited_without_kaminari kls
|
|
kls.send(:include, Kaminari::ActiveRecordModelExtension) if kls.superclass == ActiveRecord::Base
|
|
end
|
|
alias_method_chain :inherited, :kaminari
|
|
end
|
|
|
|
# Existing subclasses pick up the model extension as well
|
|
self.descendants.each do |kls|
|
|
kls.send(:include, Kaminari::ActiveRecordModelExtension) if kls.superclass == ActiveRecord::Base
|
|
end
|
|
end
|
|
end
|
|
end
|