2011-11-21 06:14:03 -05:00
|
|
|
module Kaminari
|
|
|
|
class Hooks
|
2012-05-21 07:04:27 -04:00
|
|
|
def self.init
|
2011-11-21 06:14:03 -05:00
|
|
|
ActiveSupport.on_load(:active_record) do
|
|
|
|
require 'kaminari/models/active_record_extension'
|
|
|
|
::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension
|
|
|
|
end
|
|
|
|
|
2012-05-21 07:02:37 -04:00
|
|
|
begin; require 'data_mapper'; rescue LoadError; end
|
|
|
|
if defined? ::DataMapper
|
2012-07-17 10:25:26 -04:00
|
|
|
require 'dm-aggregates'
|
2012-05-21 07:02:37 -04:00
|
|
|
require 'kaminari/models/data_mapper_extension'
|
|
|
|
::DataMapper::Collection.send :include, Kaminari::DataMapperExtension::Collection
|
|
|
|
::DataMapper::Model.append_extensions Kaminari::DataMapperExtension::Model
|
|
|
|
# ::DataMapper::Model.send :extend, Kaminari::DataMapperExtension::Model
|
|
|
|
end
|
|
|
|
|
|
|
|
begin; require 'mongoid'; rescue LoadError; end
|
2011-11-21 06:14:03 -05:00
|
|
|
if defined? ::Mongoid
|
|
|
|
require 'kaminari/models/mongoid_extension'
|
|
|
|
::Mongoid::Criteria.send :include, Kaminari::MongoidExtension::Criteria
|
2012-05-21 07:02:37 -04:00
|
|
|
::Mongoid::Document.send :include, Kaminari::MongoidExtension::Document
|
2011-11-21 06:14:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
ActiveSupport.on_load(:mongo_mapper) do
|
|
|
|
require 'kaminari/models/mongo_mapper_extension'
|
|
|
|
::MongoMapper::Document.send :include, Kaminari::MongoMapperExtension::Document
|
|
|
|
::Plucky::Query.send :include, Kaminari::PluckyCriteriaMethods
|
|
|
|
end
|
|
|
|
require 'kaminari/models/array_extension'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|