From 63d4973885c3d069817487d221ff930456fd96f2 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 8 Apr 2015 22:55:44 +0530 Subject: [PATCH] Use fewer conditionals & simplify the required files --- lib/ransack.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ransack.rb b/lib/ransack.rb index cb90271..136ea30 100644 --- a/lib/ransack.rb +++ b/lib/ransack.rb @@ -10,7 +10,6 @@ end module Ransack extend Configuration - class UntraversableAssociationError < StandardError; end; end @@ -18,20 +17,26 @@ Ransack.configure do |config| Ransack::Constants::AREL_PREDICATES.each do |name| config.add_predicate name, :arel_predicate => name end - Ransack::Constants::DERIVED_PREDICATES.each do |args| config.add_predicate *args end end -require 'ransack/translate' -require 'ransack/adapters/active_record/ransack/translate' if defined?(::ActiveRecord::Base) -require 'ransack/adapters/mongoid/ransack/translate' if defined?(::Mongoid) require 'ransack/search' require 'ransack/ransacker' -require 'ransack/adapters/active_record' if defined?(::ActiveRecord::Base) -require 'ransack/adapters/mongoid' if defined?(::Mongoid) require 'ransack/helpers' require 'action_controller' +require 'ransack/translate' + +if defined?(::ActiveRecord::Base) + require 'ransack/adapters/active_record/ransack/translate' + require 'ransack/adapters/active_record' +end + +if defined?(::Mongoid) + require 'ransack/adapters/mongoid/ransack/translate' + require 'ransack/adapters/mongoid' +end + ActionController::Base.helper Ransack::Helpers::FormHelper