Sha256: c589fd40e885823b0f8a43c7cd39ff3864f0da8703ee62332bdb849bb1e170ec

Contents?: true

Size: 1.5 KB

Versions: 22

Compression:

Stored size: 1.5 KB

Contents

module Ransack
  module Adapters

    def self.object_mapper
      @object_mapper ||= instantiate_object_mapper
    end

    def self.instantiate_object_mapper
      if defined?(::ActiveRecord::Base)
        ActiveRecordAdapter.new
      elsif defined?(::Mongoid)
        MongoidAdapter.new
      else
        raise "Unsupported adapter"
      end
    end

    class ActiveRecordAdapter
      def require_constants
        require 'ransack/adapters/active_record/ransack/constants'
      end

      def require_adapter
        require 'ransack/adapters/active_record/ransack/translate'
        require 'ransack/adapters/active_record'
      end

      def require_context
        require 'ransack/adapters/active_record/ransack/visitor'
      end

      def require_nodes
        require 'ransack/adapters/active_record/ransack/nodes/condition'
      end

      def require_search
        require 'ransack/adapters/active_record/ransack/context'
      end
    end

    class MongoidAdapter
      def require_constants
        require 'ransack/adapters/mongoid/ransack/constants'
      end

      def require_adapter
        require 'ransack/adapters/mongoid/ransack/translate'
        require 'ransack/adapters/mongoid'
      end

      def require_context
        require 'ransack/adapters/mongoid/ransack/visitor'
      end

      def require_nodes
        require 'ransack/adapters/mongoid/ransack/nodes/condition'
      end

      def require_search
        require 'ransack/adapters/mongoid/ransack/context'
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
ransack-3.2.1 lib/ransack/adapters.rb
ransack-3.2.0 lib/ransack/adapters.rb
ransack-3.1.0 lib/ransack/adapters.rb
ransack-3.0.1 lib/ransack/adapters.rb
ransack-3.0.0 lib/ransack/adapters.rb
ransack-2.6.0 lib/ransack/adapters.rb
ransack-2.5.0 lib/ransack/adapters.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/ransack-2.4.2/lib/ransack/adapters.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/ransack-2.4.2/lib/ransack/adapters.rb
ransack-2.4.2 lib/ransack/adapters.rb
ransack-2.4.1 lib/ransack/adapters.rb
ransack-2.4.0 lib/ransack/adapters.rb
ransack-2.3.2 lib/ransack/adapters.rb
ransack-2.3.1 lib/ransack/adapters.rb
ransack-2.3.0 lib/ransack/adapters.rb
ransack-1.8.10 lib/ransack/adapters.rb
ransack-2.1.1 lib/ransack/adapters.rb
ransack-2.1.0 lib/ransack/adapters.rb
ransack-2.0.1 lib/ransack/adapters.rb
ransack-2.0.0 lib/ransack/adapters.rb