mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Use AS::Concern to extend class methods
This commit is contained in:
parent
cc36733961
commit
05ff5615fa
2 changed files with 15 additions and 16 deletions
|
@ -3,16 +3,16 @@ 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
|
||||
|
||||
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
|
||||
|
|
|
@ -13,14 +13,13 @@ module Kaminari
|
|||
include Kaminari::MongoidCriteriaMethods
|
||||
include Kaminari::PageScopeMethods
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
def inherited_with_kaminari(kls)
|
||||
inherited_without_kaminari(kls)
|
||||
kls.send(:include, Kaminari::MongoidExtension::Document.dup)
|
||||
end
|
||||
alias_method_chain :inherited, :kaminari
|
||||
end unless respond_to?(:inherited_with_kaminari)
|
||||
module ClassMethods
|
||||
def inherited(kls)
|
||||
super
|
||||
kls.send(:include, Kaminari::MongoidExtension::Document.dup)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue