Sha256: 1162ee6dd499879786d3b4ce6c5348ec0374ee5a06ea5dfe378ccc6eb6d207ca

Contents?: true

Size: 937 Bytes

Versions: 23

Compression:

Stored size: 937 Bytes

Contents

module Effective
  module EffectiveDatatable
    module Params

      private

      def datatables_ajax_request?
        view && view.params[:draw] && view.params[:columns] && view.params[:id] == to_param
      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) }
      end

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

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
effective_datatables-3.2.1 app/models/effective/effective_datatable/params.rb
effective_datatables-3.2 app/models/effective/effective_datatable/params.rb
effective_datatables-3.1.3 app/models/effective/effective_datatable/params.rb
effective_datatables-3.1.2 app/models/effective/effective_datatable/params.rb
effective_datatables-3.1.1 app/models/effective/effective_datatable/params.rb
effective_datatables-3.1.0 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.16 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.15 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.14 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.13 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.12 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.11 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.10 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.9 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.8 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.7 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.6 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.5 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.4 app/models/effective/effective_datatable/params.rb
effective_datatables-3.0.3 app/models/effective/effective_datatable/params.rb