hooks.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. module Kaminari
  2. class Hooks
  3. def self.init!
  4. ActiveSupport.on_load(:active_record) do
  5. require 'kaminari/models/active_record_extension'
  6. ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension
  7. end
  8. if defined? ::Mongoid
  9. require 'kaminari/models/mongoid_extension'
  10. ::Mongoid::Document.send :include, Kaminari::MongoidExtension::Document
  11. ::Mongoid::Criteria.send :include, Kaminari::MongoidExtension::Criteria
  12. end
  13. ActiveSupport.on_load(:mongo_mapper) do
  14. require 'kaminari/models/mongo_mapper_extension'
  15. ::MongoMapper::Document.send :include, Kaminari::MongoMapperExtension::Document
  16. ::Plucky::Query.send :include, Kaminari::PluckyCriteriaMethods
  17. ::Plucky::Query.send :include, Kaminari::PageScopeMethods
  18. end
  19. if defined? ::DataMapper
  20. require 'kaminari/models/data_mapper_extension'
  21. ::DataMapper::Collection.send :include, Kaminari::DataMapperExtension::Collection
  22. ::DataMapper::Model.append_extensions Kaminari::DataMapperExtension::Model
  23. # ::DataMapper::Model.send :extend, Kaminari::DataMapperExtension::Model
  24. end
  25. require 'kaminari/models/array_extension'
  26. ActiveSupport.on_load(:action_view) do
  27. ::ActionView::Base.send :include, Kaminari::ActionViewExtension
  28. end
  29. end
  30. end
  31. end