1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00
kaminari--kaminari/lib/kaminari/models/active_record_extension.rb
2015-02-11 15:34:35 +09:00

22 lines
648 B
Ruby

require 'kaminari/models/active_record_model_extension'
module Kaminari
module ActiveRecordExtension
extend ActiveSupport::Concern
module ClassMethods
# Future subclasses will pick up the model extension
def inherited(kls) #:nodoc:
super
kls.send(:include, Kaminari::ActiveRecordModelExtension) if kls.superclass == ::ActiveRecord::Base
end
end
included do
# 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