1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00
activerecord-hackery--ransack/lib/ransack/adapters.rb
Андрей Большов 152b2509ff ActiveRecord excludes Mongoid
2015-05-22 18:46:28 +03:00

42 lines
1.5 KiB
Ruby

module Ransack
module Adapters
def self.current_adapters
@current_adapters ||= {
:active_record => defined?(::ActiveRecord::Base),
:mongoid => defined?(::Mongoid) && !defined?(::ActiveRecord::Base)
}
end
def self.require_constants
require 'ransack/adapters/mongoid/ransack/constants' if current_adapters[:mongoid]
require 'ransack/adapters/active_record/ransack/constants' if current_adapters[:active_record]
end
def self.require_adapter
if current_adapters[:active_record]
require 'ransack/adapters/active_record/ransack/translate'
require 'ransack/adapters/active_record'
end
if current_adapters[:mongoid]
require 'ransack/adapters/mongoid/ransack/translate'
require 'ransack/adapters/mongoid'
end
end
def self.require_context
require 'ransack/adapters/active_record/ransack/visitor' if current_adapters[:active_record]
require 'ransack/adapters/mongoid/ransack/visitor' if current_adapters[:mongoid]
end
def self.require_nodes
require 'ransack/adapters/active_record/ransack/nodes/condition' if current_adapters[:active_record]
require 'ransack/adapters/mongoid/ransack/nodes/condition' if current_adapters[:mongoid]
end
def self.require_search
require 'ransack/adapters/active_record/ransack/context' if current_adapters[:active_record]
require 'ransack/adapters/mongoid/ransack/context' if current_adapters[:mongoid]
end
end
end