Module: Ransack::Adapters

Defined in:
lib/ransack/adapters.rb,
lib/ransack/adapters/mongoid/base.rb,
lib/ransack/adapters/mongoid/table.rb,
lib/ransack/adapters/mongoid/context.rb,
lib/ransack/adapters/active_record/base.rb,
lib/ransack/adapters/mongoid/inquiry_hash.rb,
lib/ransack/adapters/active_record/context.rb,
lib/ransack/adapters/active_record/3.0/context.rb,
lib/ransack/adapters/active_record/3.1/context.rb,
lib/ransack/adapters/active_record/3.2/context.rb,
lib/ransack/adapters/mongoid/attributes/attribute.rb,
lib/ransack/adapters/mongoid/attributes/predications.rb,
lib/ransack/adapters/mongoid/attributes/order_predications.rb

Defined Under Namespace

Modules: ActiveRecord, Mongoid

Class Method Summary collapse

Class Method Details

.current_adaptersObject



4
5
6
7
8
9
# File 'lib/ransack/adapters.rb', line 4

def self.current_adapters
  @current_adapters ||= {
    :active_record => defined?(::ActiveRecord::Base),
    :mongoid => defined?(::Mongoid) && !defined?(::ActiveRecord::Base)
  }
end

.require_adapterObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ransack/adapters.rb', line 15

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

.require_constantsObject



10
11
12
13
# File 'lib/ransack/adapters.rb', line 10

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

.require_contextObject



27
28
29
30
# File 'lib/ransack/adapters.rb', line 27

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

.require_nodesObject



32
33
34
35
# File 'lib/ransack/adapters.rb', line 32

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

.require_searchObject



37
38
39
40
# File 'lib/ransack/adapters.rb', line 37

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