Sha256: 3328b367e6692b11d48ef44d3cce50e1af6b0e21fcd8fdca51c116b2dc890715

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

module Effective
  module EffectiveDatatable
    module Params

      private

      def datatables_ajax_request?
        return @_datatables_ajax_request unless @_datatables_ajax_request.nil?

        @_datatables_ajax_request =
          (view && view.params[:draw] && view.params[:columns] && cookie_keys.include?(view.params[:cookie])) == true
      end

      def datatables_inline_request?
        return @_datatables_inline_request unless @_datatables_inline_request.nil?

        @_datatables_inline_request =
          (view && view.params[:_datatable_cookie] && cookie_keys.include?(view.params[:_datatable_cookie])) == true
      end

      def params
        return {} unless view.present?
        @params ||= {}.tap do |params|
          Rack::Utils.parse_query(URI(view.request.referer.presence || '/').query).each { |k, v| params[k.to_sym] = v }
          view.params.each { |k, v| params[k.to_sym] = v }
        end
      end

      def filter_params
        params.select { |name, value| _filters.key?(name.to_sym) && name != 'id' }
      end

      def scope_param
        params[:scope].to_sym if params.key?(:scope)
      end

      def search_params
        params.select do |name, value|
          columns.key?(name) && ![:id, :action].include?(name) && !value.kind_of?(Hash) && value.class.name != 'ActionController::Parameters'.freeze
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
effective_datatables-4.3.21 app/models/effective/effective_datatable/params.rb
effective_datatables-4.3.20 app/models/effective/effective_datatable/params.rb
effective_datatables-4.3.19 app/models/effective/effective_datatable/params.rb
effective_datatables-4.3.18 app/models/effective/effective_datatable/params.rb
effective_datatables-4.3.17 app/models/effective/effective_datatable/params.rb
effective_datatables-4.3.16 app/models/effective/effective_datatable/params.rb
effective_datatables-4.3.15 app/models/effective/effective_datatable/params.rb